Update UpdateService.cs

This commit is contained in:
sshcomm 2025-01-29 23:26:12 +03:30 committed by GitHub
parent 6d5bd414a5
commit fde71068e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}
}
}