CommunityShare¶
Namespace Nfty.Core.Publish.Community in assembly Nfty.Core.
The share run (spec 7.2): scan, pack, check, preview, Release, upload, manifest, pull request, and the undo of whatever a failed or canceled run made. UI-free.
Remarks¶
Callers serialize share and remove runs per account. Tags and branches are deleted by name, and the run numbers its Release from the repository it just read, so two runs at once could delete each other's work.
The HttpClient behind the GitHubShareClient must have Timeout = InfiniteTimeSpan: a 200 MB upload outlasts the default 100 seconds. The client bounds response bodies itself and the caller's token stops the run.
Rollback takes back only what this run created (the Release it made, its tag, a branch it made, the repo if it made it) and restores nfty-public.json and README.md to what they held. The replaced share is never touched. Cleanup ignores the caller's token, is bounded to 30 seconds, and never hides the original failure. A repository can only be deleted with a scope sharing does not ask for, so that step is best effort; the run therefore leaves a freshly made repository holding an empty nfty-public.json, one nfty still recognizes.
Methods¶
FinishAsync(GitHubShareClient, GitHubUser, PendingShare, CancellationToken, CommunityEndpoints?)¶
public static Task FinishAsync(GitHubShareClient client, GitHubUser user, PendingShare pending, CancellationToken ct, CommunityEndpoints? endpoints = null);
Deletes the Release and tag a merged pull request made obsolete. Does nothing while the pull request is not merged, and never touches a tag some share in nfty-public.json still lists.
Parameters
client(GitHubShareClient) - GitHub.user(GitHubUser) - The signed-in account.pending(PendingShare) - What the run returned.ct(CancellationToken) - Cancellation.endpoints(CommunityEndpoints?) - Where the gallery lives; the shipped one when omitted.
ListingProblem(string?, string?, IReadOnlyList<string>?)¶
public static string? ListingProblem(string? name, string? description, IReadOnlyList<string>? tags);
The first thing wrong with a listing's words, in ShareRules' sentences, or null when they are fine.
Parameters
name(string?) - The listing's name.description(string?) - The listing's description, or null for none.tags(IReadOnlyList<string>?) - The listing's tags, or null for none.
Returns. The sentence, or null.
Remarks
One rule for the run and for the share card, so the card cannot enable Share for words the run refuses.
Options(ShareRequest)¶
The export the card plans and the run performs: the Asset pack, one archive, never sealed.
Parameters
request(ShareRequest) - What the person asked for.
Returns. The export options the share uses.
RunAsync(GitHubShareClient, GitHubUser, ShareRequest, CommunityEndpoints, string, IProgress<ShareProgress>?, CancellationToken, IReadOnlyCollection<string>, Func<DateTimeOffset>?, Func<TimeSpan, CancellationToken, Task>?)¶
public static Task<ShareResult> RunAsync(GitHubShareClient client, GitHubUser user, ShareRequest request, CommunityEndpoints endpoints, string tempRoot, IProgress<ShareProgress>? progress, CancellationToken ct, IReadOnlyCollection<string> protectedTags, Func<DateTimeOffset>? clock = null, Func<TimeSpan, CancellationToken, Task>? delay = null);
Shares, updates or swaps; see the type's remarks for what the caller owes.
Parameters
client(GitHubShareClient) - GitHub.user(GitHubUser) - The signed-in account.request(ShareRequest) - What to share.endpoints(CommunityEndpoints) - Where the gallery lives.tempRoot(string) - A folder to work in; the run cleans up what it makes there.progress(IProgress<ShareProgress>?) - Progress, in order.ct(CancellationToken) - Stops the run (and rolls it back).protectedTags(IReadOnlyCollection<string>) - Release tags the scan must never call extras: what the gallery lists for the account and what any open pull request names (PublicRepoScan.FetchAsync()). Empty only when nothing is listed or pending.clock(Func<DateTimeOffset>?) - The time stamped on the entry; tests inject one.delay(Func<TimeSpan, CancellationToken, Task>?) - The wait between polls of a new fork; tests inject one.
Returns. The pull request and what to do once it merges.
Exceptions
CommunityException- Anything that keeps the share out, inShareRules' words.
UnshareAsync(GitHubShareClient, GitHubUser, string, CommunityEndpoints, CancellationToken, Func<TimeSpan, CancellationToken, Task>?)¶
public static Task<int> UnshareAsync(GitHubShareClient client, GitHubUser user, string slug, CommunityEndpoints endpoints, CancellationToken ct, Func<TimeSpan, CancellationToken, Task>? delay = null);
Opens a pull request that deletes one of the account's entries, and takes the share out of nfty-public.json and README.md. The repository is never deleted, and the Release stays until the pull request merges (CommunityShare.FinishAsync() with ReplacedTag set to the share's tag).
Parameters
client(GitHubShareClient) - GitHub.user(GitHubUser) - The signed-in account.slug(string) - The share to remove.endpoints(CommunityEndpoints) - Where the gallery lives.ct(CancellationToken) - Cancellation (rolls back).delay(Func<TimeSpan, CancellationToken, Task>?) - The wait between polls of a new fork; tests inject one.
Returns. The pull request number.