Skip to content
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

stop fastzip from extracting on cancellation #2996

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bro just do it as a lambda function

{
// 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