Browse Source

Switch to managed unzip in prereq

pull/55/head
Ionite 1 year ago
parent
commit
6397ad702d
No known key found for this signature in database
  1. 12
      StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs
  2. 13
      StabilityMatrix.Core/Helper/ArchiveHelper.cs

12
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,

13
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.
/// </summary>
/// <param name="archivePath"></param>
/// <param name="outputDirectory">Output directory, created if does not exist.</param>
public static async Task ExtractManaged(string archivePath, string outputDirectory)
{
await using var stream = File.OpenRead(archivePath);
await ExtractManaged(stream, outputDirectory);
}
/// <summary>
/// Extract an archive to the output directory, using SharpCompress managed code.
/// does not require 7z to be installed, but no progress reporting.
/// </summary>
public static async Task ExtractManaged(Stream stream, string outputDirectory)
{
using var reader = ReaderFactory.Open(stream);
while (reader.MoveToNextEntry())
{

Loading…
Cancel
Save