From fde71068e17898fe60abba4d2cc5ef1400f859d3 Mon Sep 17 00:00:00 2001 From: sshcomm Date: Wed, 29 Jan 2025 23:26:12 +0330 Subject: [PATCH] Update UpdateService.cs --- v2rayN/ServiceLib/Services/UpdateService.cs | 39 ++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index d737459c..a942b99b 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -66,6 +66,43 @@ namespace ServiceLib.Services try { + var toPath = Utils.GetBinPath("", type.ToString()); + if (!Directory.Exists(toPath)) + { + Directory.CreateDirectory(toPath); + } + + if (fileName.Contains(".tar.gz")) + { + FileManager.DecompressTarFile(fileName, toPath); + var dir = new DirectoryInfo(toPath); + if (dir.Exists) + { + foreach (var subDir in dir.GetDirectories()) + { + FileManager.CopyDirectory(subDir.FullName, toPath, false, true); + subDir.Delete(true); + } + } + } + else if (fileName.Contains(".gz")) + { + FileManager.DecompressFile(fileName, toPath, type.ToString()); + } + else + { + FileManager.ZipExtractToFile(fileName, toPath, ""); + } + + if (Utils.IsNonWindows()) + { + var coreFile = Path.Combine(toPath, type.ToString().ToLower()); + if (File.Exists(coreFile)) + { + Utils.SetLinuxChmod(coreFile).Wait(); + } + } + _updateFunc?.Invoke(true, fileName); } catch (Exception ex) @@ -586,4 +623,4 @@ namespace ServiceLib.Services #endregion Geo private } -} \ No newline at end of file +}