From 10a60b26fa13bed56257b78870172a0e630d912b Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Tue, 22 Oct 2024 20:08:33 +0800 Subject: [PATCH] After the Linux version updates the core, set chmod+x --- v2rayN/ServiceLib/Common/Utils.cs | 7 +++++++ .../ServiceLib/ViewModels/CheckUpdateViewModel.cs | 13 +++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index ec381d81..e78ca965 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -806,6 +806,13 @@ namespace ServiceLib.Common return await GetCliWrapOutput("/bin/bash", arg); } + public static async Task SetLinuxChmod(string? fileName) + { + if (fileName.IsNullOrEmpty()) return null; + var arg = new List() { "-c", $"chmod +x {fileName}" }; + return await GetCliWrapOutput("/bin/bash", arg); + } + #endregion Platform } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index 13249f85..e7fe3195 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -182,7 +182,7 @@ namespace ServiceLib.ViewModels { _updateView?.Invoke(EViewAction.DispatcherCheckUpdateFinished, false); await Task.Delay(2000); - UpgradeCore(); + await UpgradeCore(); if (_lstUpdated.Any(x => x.CoreType == _v2rayN && x.IsFinished == true)) { @@ -228,7 +228,7 @@ namespace ServiceLib.ViewModels } } - private void UpgradeCore() + private async Task UpgradeCore() { foreach (var item in _lstUpdated) { @@ -266,6 +266,15 @@ namespace ServiceLib.ViewModels FileManager.ZipExtractToFile(fileName, toPath, _config.guiItem.ignoreGeoUpdateCore ? "geo" : ""); } + if (Utils.IsLinux()) + { + var filesList = (new DirectoryInfo(toPath)).GetFiles().Select(u => u.FullName).ToList(); + foreach (var file in filesList) + { + await Utils.SetLinuxChmod(Path.Combine(toPath, item.CoreType)); + } + } + UpdateView(item.CoreType, ResUI.MsgUpdateV2rayCoreSuccessfully); if (File.Exists(fileName))