From 75bfd9aa4c88f2f5d24724ec9adcd5ef7029cd72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Concei=C3=A7=C3=A3o?= Date: Mon, 21 Mar 2022 05:38:55 +0000 Subject: [PATCH] Fix auto-upgrade for AppImage Trying to execute before make sure chmod is applied --- UVtools.Core/SystemOS/SystemAware.cs | 7 +++++-- UVtools.WPF/Structures/AppVersionChecker.cs | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/UVtools.Core/SystemOS/SystemAware.cs b/UVtools.Core/SystemOS/SystemAware.cs index 0430a24..ea19e80 100644 --- a/UVtools.Core/SystemOS/SystemAware.cs +++ b/UVtools.Core/SystemOS/SystemAware.cs @@ -13,6 +13,7 @@ using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; +using System.Threading; namespace UVtools.Core.SystemOS; @@ -240,11 +241,13 @@ public static class SystemAware } - public static void StartProcess(string name, string? arguments = null) + public static void StartProcess(string name, string? arguments = null, bool waitForCompletion = false, int waitTimeout = Timeout.Infinite) { try { - using (Process.Start(new ProcessStartInfo(name, arguments!) { UseShellExecute = true })) { } + using var process = Process.Start(new ProcessStartInfo(name, arguments!) {UseShellExecute = true}); + if (process is null) return; + if (waitForCompletion) process.WaitForExit(waitTimeout); } catch (Exception e) { diff --git a/UVtools.WPF/Structures/AppVersionChecker.cs b/UVtools.WPF/Structures/AppVersionChecker.cs index 08fa995..b569571 100644 --- a/UVtools.WPF/Structures/AppVersionChecker.cs +++ b/UVtools.WPF/Structures/AppVersionChecker.cs @@ -14,6 +14,7 @@ using System.Net.Http.Headers; using System.Runtime.InteropServices; using System.Text.Json.Nodes; using System.Text.RegularExpressions; +using System.Threading; using System.Threading.Tasks; using Avalonia.Threading; using UVtools.Core; @@ -223,7 +224,8 @@ public class AppVersionChecker : BindableBase if (File.Exists(appImagePath)) File.Delete(appImagePath); File.Move(DownloadedFile, newFullPath, true); - SystemAware.StartProcess("chmod", $"a+x \"{newFullPath}\""); + SystemAware.StartProcess("chmod", $"a+x \"{newFullPath}\"", true); + Thread.Sleep(500); SystemAware.StartProcess(newFullPath); } else // others