Conversation
| Dictionary<DedupIdentifier, long> dedupToSize = new(); | ||
| foreach (ContentHash hash in dedupToHash.Values) | ||
| { | ||
| StreamWithLength? streamWithLength = await LocalCacheSession |
There was a problem hiding this comment.
Probably need to using so it gets disposed.
| hash => hash); | ||
|
|
||
| // open a stream to get the length of all content | ||
| Dictionary<DedupIdentifier, long> dedupToSize = new(); |
|
|
||
| foreach (KeyValuePair<string, ContentHash> output in outputs) | ||
| { | ||
| string relativePath = output.Key.MakePathRelativeTo(RepoRoot)!.Replace("\\", "/", StringComparison.Ordinal); |
There was a problem hiding this comment.
Should merge with the latest and use the helper
| relativePath, | ||
| new DedupInfo(dedupId.ValueString, (ulong)dedupToSize[dedupId]))); | ||
| } | ||
| items.Sort((i1, i2) => StringComparer.Ordinal.Compare(i1.Path, i2.Path)); |
There was a problem hiding this comment.
Should this be case-sensitive or insensitive?
| Dictionary<string, PlaceFileResult> placeResults = await TryPlaceFilesFromCacheAsync(context, tempFiles, cancellationToken); | ||
| foreach (PlaceFileResult placeResult in placeResults.Values) | ||
| // Store the manifest in local cache to simplify the code below | ||
| using MemoryStream manifestStream = new(JsonSerializer.Serialize(manifest).GetUTF8Bytes()); |
There was a problem hiding this comment.
I believe you can serialize directly to a stream, which should cut out the intermediate string.
| Dictionary<DedupIdentifier, CheckIfUploadNeededResult> uploadCheckResults = | ||
| await uploadSession.CheckIfUploadIsNeededAsync(dedupToSize, cancellationToken); | ||
|
|
||
| IEnumerable<DedupIdentifier> hashesToupload = uploadCheckResults |
There was a problem hiding this comment.
Nit: hashesToupload -> hashesToUpload
| } | ||
| else | ||
| { | ||
| DedupNode node = await ChunkFileAsync(kvp.Value, cancellationToken); |
There was a problem hiding this comment.
Does this re-hash the file? That seems a bit expensive :(
| // 3. map all the relative paths to the temp files | ||
| foreach (KeyValuePair<string, ContentHash> output in outputs) | ||
|
|
||
| while (pageRoots.Count > 1) |
There was a problem hiding this comment.
> 0? If not, might need to add a comment explaining why
| pageRoots = newPageRoots; | ||
| } | ||
|
|
||
| DedupNode root = pageRoots.Single(); |
|
|
||
| DedupNode root = pageRoots.Single(); | ||
|
|
||
| HashSet<DedupNode> proofNodes = ProofHelper.CreateProofNodes( |
There was a problem hiding this comment.
Can you explain what "proof" is?
| } | ||
| } | ||
|
|
||
| private static Task<DedupNode> ChunkFileAsync(string path, CancellationToken cancellationToken) => |
There was a problem hiding this comment.
This is used exactly once and is 1 line. Consider inlining it.
| infos = outputs.Keys.Select(f => new FileInfo(f)).ToArray(); | ||
| FileInfo[] infos = outputs.Keys.Select(f => new FileInfo(f)).ToArray(); | ||
| publishResult = await WithHttpRetries( | ||
| () => _manifestClient.PublishAsync(RepoRoot, infos, extras, new ArtifactPublishOptions(), manifestFileOutputPath: null, cancellationToken), |
There was a problem hiding this comment.
Do similar things need to be done here?
No description provided.