Skip to content

Commit

Permalink
Fix 7z process arguments for paths with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ionite34 committed Jul 3, 2023
1 parent ec06397 commit a1ba088
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions StabilityMatrix/Helper/ArchiveHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ public static async Task AddToArchive7Z(string archivePath, string sourceDirecto

public static async Task<ArchiveInfo> 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);
Expand Down Expand Up @@ -85,10 +84,9 @@ public static async Task<ArchiveInfo> 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();

Expand Down

0 comments on commit a1ba088

Please sign in to comment.