Skip to content

Conversation

@johnterickson
Copy link
Collaborator

No description provided.

Dictionary<DedupIdentifier, long> dedupToSize = new();
foreach (ContentHash hash in dedupToHash.Values)
{
StreamWithLength? streamWithLength = await LocalCacheSession
Copy link
Member

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();
Copy link
Member

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);
Copy link
Member

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));
Copy link
Member

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());
Copy link
Member

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
Copy link
Member

@dfederm dfederm Jan 26, 2024

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);
Copy link
Member

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)
Copy link
Member

@dfederm dfederm Jan 26, 2024

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

pageRoots = newPageRoots;
}

DedupNode root = pageRoots.Single();
Copy link
Member

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(
Copy link
Member

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?

}
}

private static Task<DedupNode> ChunkFileAsync(string path, CancellationToken cancellationToken) =>
Copy link
Member

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),
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants