server self-update fix
This commit is contained in:
parent
fd8bdf763f
commit
c4cac772f0
@ -13,11 +13,11 @@ static class Updates
|
|||||||
var updatedFiles = Directory.GetAllFiles(updatesDir);
|
var updatedFiles = Directory.GetAllFiles(updatesDir);
|
||||||
if(updatedFiles.Count != 0) Server.Logger.LogInfo(nameof(Check), $"updated files found in '{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")
|
var relativeFilePath = updatedFilePath.RemoveBase(updatesDir);
|
||||||
SelfUpdate(updatesDir, f);
|
if(relativeFilePath.Str is "minecraft-launcher-server" or "minecraft-launcher-server.exe")
|
||||||
return;
|
SelfUpdate(updatedFilePath, relativeFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var updatedFilePath in updatedFiles)
|
foreach (var updatedFilePath in updatedFiles)
|
||||||
@ -57,11 +57,11 @@ static class Updates
|
|||||||
File.Move(updatedFilePath, Server.LatestLauncherVersionFile, true);
|
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...");
|
Server.Logger.LogWarn(nameof(SelfUpdate), "program update found, restarting...");
|
||||||
IOPath exeFileNew = exeFile + "_new";
|
IOPath exeFileNew = exeFile + "_new";
|
||||||
File.Move(Path.Concat(updatesDir, exeFile), exeFileNew, true);
|
File.Move(updatedFile, 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
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user