-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index.json in Consolidated zip stores full path, not just hash #1416
base: release/27.3.5
Are you sure you want to change the base?
Changes from 2 commits
bb638b0
0e01902
10b59eb
006a8f9
fa400b5
6c011a6
f698882
2d8e9c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,39 +24,33 @@ public static void Create(IEnumerable<SourceFile> sourceFiles, string destinatio | |
|
||
private static void WriteUniqueFilesToZip(IEnumerable<SourceFile> sourceFiles, ZipArchive zip) | ||
{ | ||
// This acts as a 'Distinct' - there may be multiples of a given file which are binary-identical | ||
// therefore we only need to track ONE (aka the first) of these files during packing. | ||
var uniqueFiles = sourceFiles | ||
.GroupBy(sourceFile => new {sourceFile.FullNameInDestinationArchive, sourceFile.Hash}) | ||
.Select(g => new | ||
{ | ||
g.Key.FullNameInDestinationArchive, | ||
g.Key.Hash, | ||
g.First().FullNameInSourceArchive, | ||
g.First().ArchivePath | ||
}); | ||
.DistinctBy(sourceFile => sourceFile.EntryNameInConsolidationArchive()); | ||
|
||
foreach (var groupedBySourceArchive in uniqueFiles.GroupBy(f => f.ArchivePath)) | ||
{ | ||
using (var sourceZip = ZipFile.OpenRead(groupedBySourceArchive.Key)) | ||
foreach (var uniqueFile in groupedBySourceArchive) | ||
{ | ||
var entryName = Path.Combine(uniqueFile.Hash, uniqueFile.FullNameInDestinationArchive); | ||
var entry = zip.CreateEntry(entryName, CompressionLevel.Fastest); | ||
|
||
var entry = zip.CreateEntry(uniqueFile.EntryNameInConsolidationArchive(), CompressionLevel.Fastest); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could |
||
using (var destStream = entry.Open()) | ||
using (var sourceStream = sourceZip.Entries.First(e => e.FullName == uniqueFile.FullNameInSourceArchive).Open()) | ||
sourceStream.CopyTo(destStream); | ||
} | ||
} | ||
} | ||
|
||
private static void WriteIndexTo(Stream stream, IEnumerable<SourceFile> sourceFiles) | ||
{ | ||
Dictionary<string, string[]> GroupByPlatform(IEnumerable<SourceFile> filesForPackage) | ||
// SHould break out entryName to a function - make first class | ||
Dictionary<string, FileTransfer[]> GroupByPlatform(IEnumerable<SourceFile> filesForPackage) | ||
=> filesForPackage | ||
.GroupBy(f => f.Platform) | ||
.ToDictionary( | ||
g => g.Key, | ||
g => g.Select(f => f.Hash).OrderBy(h => h).ToArray() | ||
.GroupBy(f => f.Platform) | ||
.ToDictionary( | ||
g => g.Key, | ||
g => g.Select(f => new FileTransfer(f.EntryNameInConsolidationArchive(), f.FullNameInDestinationArchive)).ToArray() | ||
); | ||
|
||
var index = new ConsolidatedPackageIndex( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,18 +14,20 @@ public ConsolidatedPackageIndex(Dictionary<string, Package> packages) | |
|
||
public class Package | ||
{ | ||
public Package(string packageId, string version, bool isNupkg, Dictionary<string, string[]> platformHashes) | ||
public Package(string packageId, string version, bool isNupkg, Dictionary<string, FileTransfer[]> platformHashes) | ||
{ | ||
PackageId = packageId; | ||
Version = version; | ||
IsNupkg = isNupkg; | ||
PlatformHashes = new Dictionary<string, string[]>(platformHashes, StringComparer.OrdinalIgnoreCase); | ||
PlatformHashes = new Dictionary<string, FileTransfer[]>(platformHashes, StringComparer.OrdinalIgnoreCase); | ||
} | ||
|
||
public string PackageId { get; } | ||
public string Version { get; } | ||
public bool IsNupkg { get; } | ||
public Dictionary<string, string[]> PlatformHashes { get; } | ||
public Dictionary<string, FileTransfer[]> PlatformHashes { get; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
} | ||
|
||
public record FileTransfer(String Source, string Destination); | ||
} |
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.
FWIW entry.Name should give you the file name