refactor: updater argument parse to fix path with space

This commit is contained in:
ChsBuffer
2020-10-13 19:13:46 +08:00
parent be4a18d599
commit 5af2749760
2 changed files with 7 additions and 6 deletions

View File

@@ -73,7 +73,7 @@ namespace Netch.Forms
{
FileName = Path.Combine(Global.NetchDir, "NetchUpdater.exe"),
Arguments =
$"{Global.Settings.UDPSocketPort} {fileFullPath} {Global.NetchDir}"
$"{Global.Settings.UDPSocketPort}|{fileFullPath}|{Global.NetchDir}"
});
}
}

View File

@@ -25,10 +25,11 @@ namespace NetchUpdater
UpdaterFriendlyName = Path.GetFileName(UpdaterFullName);
}
public static void Main(string[] args)
public static void Main(string[] args1)
{
var result = false;
var args = args1.Aggregate((s, s1) => $"{s} {s1}").Split('|').Select(s => s.Trim()).ToArray();
try
{
#region Check Arguments
@@ -86,7 +87,7 @@ namespace NetchUpdater
Process.Start(new ProcessStartInfo
{
FileName = newUpdaterPath,
Arguments = $"{port} {updatePath} {targetPath}",
Arguments = $"{port}|{updatePath}|{targetPath}",
WorkingDirectory = tempPath,
UseShellExecute = false
});
@@ -98,9 +99,9 @@ namespace NetchUpdater
#endregion
/*while (!Debugger.IsAttached)
/*Console.WriteLine("Waiting Attach");
while (!Debugger.IsAttached)
{
Console.WriteLine("Waiting Attach");
Thread.Sleep(1000);
}*/
@@ -221,7 +222,7 @@ namespace NetchUpdater
File.WriteAllBytes("7za.exe", Resources._7za);
var argument = new StringBuilder();
argument.Append($" x {archiveFileName} -o{destDirName} ");
argument.Append($" x \"{archiveFileName}\" -o\"{destDirName}\" ");
if (overwrite)
argument.Append(" -y ");