Calculate detailed progress for release extraction

This commit is contained in:
Geert van Horrik
2020-08-31 10:31:45 +02:00
parent c2a1db6181
commit 9ffea683d0
2 changed files with 17 additions and 1 deletions

View File

@@ -191,13 +191,26 @@ namespace Squirrel
}
public static Task ExtractZipForInstall(string zipFilePath, string outFolder, string rootPackageFolder)
{
return ExtractZipForInstall(zipFilePath, outFolder, rootPackageFolder, x => { });
}
public static Task ExtractZipForInstall(string zipFilePath, string outFolder, string rootPackageFolder, Action<int> progress)
{
var re = new Regex(@"lib[\\\/][^\\\/]*[\\\/]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
return Task.Run(() => {
using (var za = ZipArchive.Open(zipFilePath))
using (var reader = za.ExtractAllEntries()) {
var totalItems = za.Entries.Count;
var currentItem = 0;
while (reader.MoveToNextEntry()) {
// Report progress early since we might be need to continue for non-matches
currentItem++;
var percentage = (currentItem * 100d) / totalItems;
progress((int)percentage);
var parts = reader.Entry.Key.Split('\\', '/');
var decoded = String.Join(Path.DirectorySeparatorChar.ToString(), parts);
@@ -234,6 +247,8 @@ namespace Squirrel
}
}
}
progress(100);
});
}

View File

@@ -312,7 +312,8 @@ namespace Squirrel
await ReleasePackage.ExtractZipForInstall(
Path.Combine(updateInfo.PackageDirectory, release.Filename),
target.FullName,
rootAppDirectory);
rootAppDirectory,
progressCallback);
return target.FullName;
});