From a1ba088b0f88860d9638fbd0fbe163e06e44273c Mon Sep 17 00:00:00 2001 From: Ionite Date: Sun, 2 Jul 2023 22:47:46 -0400 Subject: [PATCH] Fix 7z process arguments for paths with spaces --- StabilityMatrix/Helper/ArchiveHelper.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/StabilityMatrix/Helper/ArchiveHelper.cs b/StabilityMatrix/Helper/ArchiveHelper.cs index 3e794b6b5..becaaccad 100644 --- a/StabilityMatrix/Helper/ArchiveHelper.cs +++ b/StabilityMatrix/Helper/ArchiveHelper.cs @@ -54,10 +54,9 @@ public static async Task AddToArchive7Z(string archivePath, string sourceDirecto public static async Task Extract7Z(string archivePath, string extractDirectory) { - var process = ProcessRunner.StartProcess(SevenZipPath, new[] - { - "x", archivePath, $"-o{ProcessRunner.Quote(extractDirectory)}", "-y" - }); + var args = + $"x {ProcessRunner.Quote(archivePath)} -o{ProcessRunner.Quote(extractDirectory)} -y"; + var process = ProcessRunner.StartProcess(SevenZipPath, args); await ProcessRunner.WaitForExitConditionAsync(process); var output = await process.StandardOutput.ReadToEndAsync(); var matches = Regex7ZOutput.Matches(output); @@ -85,10 +84,9 @@ public static async Task Extract7Z(string archivePath, string extra progress.Report(new ProgressReport(-1, isIndeterminate: true, type: ProgressType.Extract)); // Need -bsp1 for progress reports - var process = ProcessRunner.StartProcess(SevenZipPath, new[] - { - "x", archivePath, $"-o{ProcessRunner.Quote(extractDirectory)}", "-y", "-bsp1" - }, outputDataReceived: onOutput); + var args = + $"x {ProcessRunner.Quote(archivePath)} -o{ProcessRunner.Quote(extractDirectory)} -y -bsp1"; + var process = ProcessRunner.StartProcess(SevenZipPath, args, outputDataReceived: onOutput); await process.WaitForExitAsync();