Skip to content

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

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

}

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?

@@ -377,6 +493,9 @@ internal sealed class PipelineCachingCacheClient : CacheClient
}
}

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?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants