Skip to content

Commit

Permalink
stop fastzip from extracting on cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
bluepilledgreat committed Sep 28, 2024
1 parent 55f5ef4 commit 98e72e2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Bloxstrap/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

using Microsoft.Win32;

using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Core;

using Bloxstrap.AppData;

namespace Bloxstrap
Expand Down Expand Up @@ -1048,6 +1051,12 @@ private async Task DownloadPackage(Package package)
}
}

private void OnFastZipProcessFile(object sender, ScanEventArgs e)
{
// stop extracting if cancellation requested
e.ContinueRunning = !_cancelTokenSource.IsCancellationRequested;
}

private void ExtractPackage(Package package, List<string>? files = null)
{
const string LOG_IDENT = "Bootstrapper::ExtractPackage";
Expand All @@ -1068,7 +1077,10 @@ private void ExtractPackage(Package package, List<string>? files = null)

App.Logger.WriteLine(LOG_IDENT, $"Extracting {package.Name}...");

var fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
var events = new FastZipEvents();
events.ProcessFile += OnFastZipProcessFile;

var fastZip = new FastZip(events);
fastZip.ExtractZip(package.DownloadPath, packageFolder, fileFilter);

App.Logger.WriteLine(LOG_IDENT, $"Finished extracting {package.Name}");
Expand Down

0 comments on commit 98e72e2

Please sign in to comment.