After the Linux version updates the core, set chmod+x

This commit is contained in:
2dust 2024-10-22 20:08:33 +08:00
parent b3c2084b76
commit 10a60b26fa
2 changed files with 18 additions and 2 deletions

View file

@ -806,6 +806,13 @@ namespace ServiceLib.Common
return await GetCliWrapOutput("/bin/bash", arg); return await GetCliWrapOutput("/bin/bash", arg);
} }
public static async Task<string?> SetLinuxChmod(string? fileName)
{
if (fileName.IsNullOrEmpty()) return null;
var arg = new List<string>() { "-c", $"chmod +x {fileName}" };
return await GetCliWrapOutput("/bin/bash", arg);
}
#endregion Platform #endregion Platform
} }
} }

View file

@ -182,7 +182,7 @@ namespace ServiceLib.ViewModels
{ {
_updateView?.Invoke(EViewAction.DispatcherCheckUpdateFinished, false); _updateView?.Invoke(EViewAction.DispatcherCheckUpdateFinished, false);
await Task.Delay(2000); await Task.Delay(2000);
UpgradeCore(); await UpgradeCore();
if (_lstUpdated.Any(x => x.CoreType == _v2rayN && x.IsFinished == true)) 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) foreach (var item in _lstUpdated)
{ {
@ -266,6 +266,15 @@ namespace ServiceLib.ViewModels
FileManager.ZipExtractToFile(fileName, toPath, _config.guiItem.ignoreGeoUpdateCore ? "geo" : ""); 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); UpdateView(item.CoreType, ResUI.MsgUpdateV2rayCoreSuccessfully);
if (File.Exists(fileName)) if (File.Exists(fileName))