From 20bb263b06b3bd5b161040b6ed35f4fc9405772a Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:10:30 +0800 Subject: [PATCH] Bug fix for check update --- v2rayN/ServiceLib/Handler/UpdateHandler.cs | 7 ++++--- v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/UpdateHandler.cs b/v2rayN/ServiceLib/Handler/UpdateHandler.cs index 263214c2..3fdb7d7f 100644 --- a/v2rayN/ServiceLib/Handler/UpdateHandler.cs +++ b/v2rayN/ServiceLib/Handler/UpdateHandler.cs @@ -109,7 +109,8 @@ namespace ServiceLib.Handler _updateFunc(false, args.Msg); url = args.Url; - fileName = Utils.GetTempPath(Utils.GetGUID()); + var ext = Path.GetExtension(url); + fileName = Utils.GetTempPath(Utils.GetGUID()+ ext); await downloadHandle.DownloadFileAsync(url, fileName, true, _timeout); } else @@ -322,9 +323,9 @@ namespace ServiceLib.Handler } using Process p = new(); - p.StartInfo.FileName = filePath.AppendQuotes(); + p.StartInfo.FileName = filePath; p.StartInfo.Arguments = coreInfo.versionArg; - p.StartInfo.WorkingDirectory = Utils.StartupPath(); + p.StartInfo.WorkingDirectory = Utils.GetConfigPath(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index 45b1218d..b757f856 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -196,20 +196,20 @@ namespace ServiceLib.ViewModels }); } - private void UpdateFinished() + private async Task UpdateFinished() { if (_lstUpdated.Count > 0 && _lstUpdated.Count(x => x.isFinished == true) == _lstUpdated.Count) { _updateView?.Invoke(EViewAction.DispatcherCheckUpdateFinished, false); - Task.Delay(1000); + await Task.Delay(2000); UpgradeCore(); if (_lstUpdated.Any(x => x.coreType == _v2rayN && x.isFinished == true)) { - Task.Delay(1000); + await Task.Delay(1000); UpgradeN(); } - Task.Delay(1000); + await Task.Delay(1000); _updateView?.Invoke(EViewAction.DispatcherCheckUpdateFinished, true); } }