diff --git a/StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs b/StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs index a3cf3177..854e8fe4 100644 --- a/StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs +++ b/StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs @@ -111,14 +111,8 @@ public class UnixPrerequisiteHelper : IPrerequisiteHelper { await PythonDir.DeleteAsync(true); } - if (progress != null) - { - await ArchiveHelper.Extract7Z(downloadPath, PythonDir, progress); - } - else - { - await ArchiveHelper.Extract7Z(downloadPath, PythonDir); - } + progress?.Report(new ProgressReport(0, "Installing Python", isIndeterminate: true)); + await ArchiveHelper.ExtractManaged(downloadPath, PythonDir); // For Linux, move the inner 'python' folder up to the root PythonDir if (Compat.IsLinux) @@ -138,6 +132,8 @@ public class UnixPrerequisiteHelper : IPrerequisiteHelper // Cleanup download file File.Delete(downloadPath); } + + progress?.Report(new ProgressReport(1, "Installing Python", isIndeterminate: false)); } public Task SetupPythonDependencies(string installLocation, string requirementsFileName, diff --git a/StabilityMatrix.Core/Helper/ArchiveHelper.cs b/StabilityMatrix.Core/Helper/ArchiveHelper.cs index 0a815ebe..11151417 100644 --- a/StabilityMatrix.Core/Helper/ArchiveHelper.cs +++ b/StabilityMatrix.Core/Helper/ArchiveHelper.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.IO.Compression; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; @@ -9,6 +10,7 @@ using SharpCompress.Compressors.Deflate; using SharpCompress.Readers; using StabilityMatrix.Core.Models.Progress; using StabilityMatrix.Core.Processes; +using GZipStream = System.IO.Compression.GZipStream; using Timer = System.Timers.Timer; namespace StabilityMatrix.Core.Helper; @@ -190,11 +192,18 @@ public static class ArchiveHelper /// Extract an archive to the output directory, using SharpCompress managed code. /// does not require 7z to be installed, but no progress reporting. /// - /// - /// Output directory, created if does not exist. public static async Task ExtractManaged(string archivePath, string outputDirectory) { await using var stream = File.OpenRead(archivePath); + await ExtractManaged(stream, outputDirectory); + } + + /// + /// Extract an archive to the output directory, using SharpCompress managed code. + /// does not require 7z to be installed, but no progress reporting. + /// + public static async Task ExtractManaged(Stream stream, string outputDirectory) + { using var reader = ReaderFactory.Open(stream); while (reader.MoveToNextEntry()) {