From 88990b48283bb34f380468ce84203276390facb3 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 26 Oct 2024 18:00:22 +0800 Subject: [PATCH] Bug fix 0efb0b5e3eb97c143fcc1b32cb59a7973db53f78 --- v2rayN/ServiceLib/Handler/CoreHandler.cs | 24 +++++++------------ v2rayN/ServiceLib/Services/UpdateService.cs | 5 ++-- .../ViewModels/CheckUpdateViewModel.cs | 14 ++++------- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index c4b80381..8f230a18 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -37,9 +37,9 @@ namespace ServiceLib.Handler continue; } - foreach (var vName in it.CoreExes) + foreach (var name in it.CoreExes) { - var exe = Utils.GetExeName(Utils.GetBinPath(vName, it.CoreType.ToString())); + var exe = Utils.GetBinPath(Utils.GetExeName(name), it.CoreType.ToString()); if (File.Exists(exe)) { await Utils.SetLinuxChmod(exe); @@ -134,17 +134,12 @@ namespace ServiceLib.Handler { continue; } - foreach (string vName in it.CoreExes) + foreach (var name in it.CoreExes) { - var existing = Process.GetProcessesByName(vName); - foreach (Process p in existing) - { - string? path = p.MainModule?.FileName; - if (path == Utils.GetExeName(Utils.GetBinPath(vName, it.CoreType.ToString()))) - { - await KillProcess(p); - } - } + var path = Utils.GetBinPath(Utils.GetExeName(name), it.CoreType.ToString()); + var existing = Process.GetProcessesByName(name); + var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName.Contains(path) == true); + await KillProcess(pp); } } } @@ -173,10 +168,9 @@ namespace ServiceLib.Handler private string CoreFindExe(CoreInfo coreInfo) { string fileName = string.Empty; - foreach (string name in coreInfo.CoreExes) + foreach (var name in coreInfo.CoreExes) { - string vName = Utils.GetExeName(name); - vName = Utils.GetBinPath(vName, coreInfo.CoreType.ToString()); + var vName = Utils.GetBinPath(Utils.GetExeName(name), coreInfo.CoreType.ToString()); if (File.Exists(vName)) { fileName = vName; diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index fb15d03f..10c18f24 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -309,10 +309,9 @@ namespace ServiceLib.Services { var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type); string filePath = string.Empty; - foreach (string name in coreInfo.CoreExes) + foreach (var name in coreInfo.CoreExes) { - string vName = Utils.GetExeName(name); - vName = Utils.GetBinPath(vName, coreInfo.CoreType.ToString()); + var vName = Utils.GetBinPath(Utils.GetExeName(name), coreInfo.CoreType.ToString()); if (File.Exists(vName)) { filePath = vName; diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index 04fc910a..741bde64 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -45,16 +45,12 @@ namespace ServiceLib.ViewModels if (RuntimeInformation.ProcessArchitecture != Architecture.X86) { - if (Utils.IsWindows()) + _checkUpdateItem.Add(new CheckUpdateItem() { - _checkUpdateItem.Add(new CheckUpdateItem() - { - IsSelected = false, - CoreType = _v2rayN, - Remarks = ResUI.menuCheckUpdate, - }); - } - + IsSelected = false, + CoreType = _v2rayN, + Remarks = ResUI.menuCheckUpdate, + }); _checkUpdateItem.Add(new CheckUpdateItem() { IsSelected = true,