-
Notifications
You must be signed in to change notification settings - Fork 14
Only link what needs to be uploaded #48
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: main
Are you sure you want to change the base?
Conversation
Dictionary<DedupIdentifier, long> dedupToSize = new(); | ||
foreach (ContentHash hash in dedupToHash.Values) | ||
{ | ||
StreamWithLength? streamWithLength = await LocalCacheSession |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: initialize with a count
|
||
foreach (KeyValuePair<string, ContentHash> output in outputs) | ||
{ | ||
string relativePath = output.Key.MakePathRelativeTo(RepoRoot)!.Replace("\\", "/", StringComparison.Ordinal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: hashesToupload
-> hashesToUpload
} | ||
else | ||
{ | ||
DedupNode node = await ChunkFileAsync(kvp.Value, cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> 0
? If not, might need to add a comment explaining why
} | ||
|
||
DedupNode root = pageRoots.Single(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[0]
|
||
DedupNode root = pageRoots.Single(); | ||
|
||
HashSet<DedupNode> proofNodes = ProofHelper.CreateProofNodes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what "proof" is?
@@ -377,6 +493,9 @@ internal sealed class PipelineCachingCacheClient : CacheClient | |||
} | |||
} | |||
|
|||
private static Task<DedupNode> ChunkFileAsync(string path, CancellationToken cancellationToken) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do similar things need to be done here?
No description provided.