mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Calculate detailed progress for release extraction
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -312,7 +312,8 @@ namespace Squirrel
|
||||
await ReleasePackage.ExtractZipForInstall(
|
||||
Path.Combine(updateInfo.PackageDirectory, release.Filename),
|
||||
target.FullName,
|
||||
rootAppDirectory);
|
||||
rootAppDirectory,
|
||||
progressCallback);
|
||||
|
||||
return target.FullName;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user