server self-update fix

This commit is contained in:
Timerix22 2024-01-07 01:03:56 +06:00
parent a0f6f56e7e
commit ca8825dcd7

View File

@ -68,6 +68,7 @@ static class Server
static void CheckUpdates() static void CheckUpdates()
{ {
logger.LogInfo(nameof(CheckUpdates), "checking for updates...");
IOPath updatesDir = "updates"; IOPath updatesDir = "updates";
Directory.Create(updatesDir); Directory.Create(updatesDir);
var updatedFiles = Directory.GetAllFiles(updatesDir); var updatedFiles = Directory.GetAllFiles(updatesDir);
@ -84,7 +85,8 @@ static class Server
File.Move(relativeFilePath, exeFileNew, true); File.Move(relativeFilePath, exeFileNew, true);
if(Environment.OSVersion.Platform == PlatformID.Win32NT) if(Environment.OSVersion.Platform == PlatformID.Win32NT)
Process.Start("cmd",$"/c move {exeFileNew} {exeFile} && {exeFile}"); Process.Start("cmd",$"/c move {exeFileNew} {exeFile} && {exeFile}");
else Process.Start("bash",$"-c 'mv {exeFileNew} {exeFile}'"); else
File.Move(exeFileNew, exeFile, true);
Environment.Exit(0); Environment.Exit(0);
} }
else File.Move(updatedFilePath, relativeFilePath, true); else File.Move(updatedFilePath, relativeFilePath, true);
@ -95,7 +97,10 @@ static class Server
+ e.ToStringDemystified()); + e.ToStringDemystified());
} }
} }
logger.LogInfo(nameof(CheckUpdates), "creating manifests...");
Manifests.CreateAllManifests(); Manifests.CreateAllManifests();
logger.LogInfo(nameof(CheckUpdates), "manifests created");
logger.LogInfo(nameof(CheckUpdates), "update check completed");
} }
// запускается для каждого юзера в отдельном потоке // запускается для каждого юзера в отдельном потоке