From c4cac772f02972372e5d71546df842cfb4132d55 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Tue, 23 Jan 2024 17:41:01 +0600 Subject: [PATCH] server self-update fix --- minecraft-launcher-server/Updates.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/minecraft-launcher-server/Updates.cs b/minecraft-launcher-server/Updates.cs index 236f06b..96a84ce 100644 --- a/minecraft-launcher-server/Updates.cs +++ b/minecraft-launcher-server/Updates.cs @@ -13,11 +13,11 @@ static class Updates var updatedFiles = Directory.GetAllFiles(updatesDir); if(updatedFiles.Count != 0) Server.Logger.LogInfo(nameof(Check), $"updated files found in '{updatesDir}'"); - foreach (var f in updatedFiles) + foreach (var updatedFilePath in updatedFiles) { - if(f.Str is "minecraft-launcher-server" or "minecraft-launcher-server.exe") - SelfUpdate(updatesDir, f); - return; + var relativeFilePath = updatedFilePath.RemoveBase(updatesDir); + if(relativeFilePath.Str is "minecraft-launcher-server" or "minecraft-launcher-server.exe") + SelfUpdate(updatedFilePath, relativeFilePath); } foreach (var updatedFilePath in updatedFiles) @@ -57,11 +57,11 @@ static class Updates File.Move(updatedFilePath, Server.LatestLauncherVersionFile, true); } - public static void SelfUpdate(IOPath updatesDir, IOPath exeFile) + public static void SelfUpdate(IOPath updatedFile, IOPath exeFile) { Server.Logger.LogWarn(nameof(SelfUpdate), "program update found, restarting..."); IOPath exeFileNew = exeFile + "_new"; - File.Move(Path.Concat(updatesDir, exeFile), exeFileNew, true); + File.Move(updatedFile, exeFileNew, true); if(Environment.OSVersion.Platform == PlatformID.Win32NT) Process.Start("cmd",$"/c move {exeFileNew} {exeFile} && {exeFile}"); else