From effa0c2e856a650d15753950b5e1ab812f18a9cd Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 5 Jul 2024 22:00:38 +1000 Subject: [PATCH] dotnet: Make compiled commands/plugins backwards compatible --- CLI/MCGalaxyCLI_dotnet6.csproj | 1 + CLI/MCGalaxyCLI_dotnet7.csproj | 1 + CLI/MCGalaxyCLI_dotnet8.csproj | 1 + MCGalaxy/MCGalaxy_dotnet.csproj | 1 + MCGalaxy/Server/Maintenance/Updater.cs | 17 ++++++++++++----- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CLI/MCGalaxyCLI_dotnet6.csproj b/CLI/MCGalaxyCLI_dotnet6.csproj index 885a3c132..0fc7f13dd 100644 --- a/CLI/MCGalaxyCLI_dotnet6.csproj +++ b/CLI/MCGalaxyCLI_dotnet6.csproj @@ -3,6 +3,7 @@ Exe net6.0 true + MCGalaxyCLI diff --git a/CLI/MCGalaxyCLI_dotnet7.csproj b/CLI/MCGalaxyCLI_dotnet7.csproj index 1ffc45bb2..892c94d46 100644 --- a/CLI/MCGalaxyCLI_dotnet7.csproj +++ b/CLI/MCGalaxyCLI_dotnet7.csproj @@ -3,6 +3,7 @@ Exe net7.0 true + MCGalaxyCLI diff --git a/CLI/MCGalaxyCLI_dotnet8.csproj b/CLI/MCGalaxyCLI_dotnet8.csproj index 80fddc216..cb31ac7df 100644 --- a/CLI/MCGalaxyCLI_dotnet8.csproj +++ b/CLI/MCGalaxyCLI_dotnet8.csproj @@ -3,6 +3,7 @@ Exe net8.0 true + MCGalaxyCLI diff --git a/MCGalaxy/MCGalaxy_dotnet.csproj b/MCGalaxy/MCGalaxy_dotnet.csproj index 61ce30c08..3fe79ed47 100644 --- a/MCGalaxy/MCGalaxy_dotnet.csproj +++ b/MCGalaxy/MCGalaxy_dotnet.csproj @@ -4,6 +4,7 @@ true false $(DefineConstants);MCG_DOTNET + MCGalaxy_ diff --git a/MCGalaxy/Server/Maintenance/Updater.cs b/MCGalaxy/Server/Maintenance/Updater.cs index 03ae79e4a..02b3acd2a 100644 --- a/MCGalaxy/Server/Maintenance/Updater.cs +++ b/MCGalaxy/Server/Maintenance/Updater.cs @@ -16,6 +16,7 @@ software distributed under the Licenses are distributed on an "AS IS" permissions and limitations under the Licenses. */ using System; +using System.IO; using System.Net; using MCGalaxy.Network; using MCGalaxy.Platform; @@ -97,16 +98,16 @@ public static void PerformUpdate(bool release) { Logger.Log(LogType.SystemActivity, "Downloading {0} update files", mode); WebClient client = HttpUtil.CreateWebClient(); - client.DownloadFile(DLL_URL.Replace("{0}", mode), "MCGalaxy_.update"); + DownloadFile(client, DLL_URL.Replace("{0}", mode), "MCGalaxy_.update"); #if MCG_STANDALONE // Self contained executable, no separate CLI or GUI to download #elif MCG_DOTNET - client.DownloadFile(CLI_URL.Replace("{0}", mode), "MCGalaxyCLI.update"); + DownloadFile(client, CLI_URL.Replace("{0}", mode), "MCGalaxyCLI.update"); #else - client.DownloadFile(GUI_URL.Replace("{0}", mode), "MCGalaxy.update"); - client.DownloadFile(CLI_URL.Replace("{0}", mode), "MCGalaxyCLI.update"); + DownloadFile(client, GUI_URL.Replace("{0}", mode), "MCGalaxy.update"); + DownloadFile(client, CLI_URL.Replace("{0}", mode), "MCGalaxyCLI.update"); #endif - client.DownloadFile(CHANGELOG_URL, "Changelog.txt"); + DownloadFile(client, CHANGELOG_URL, "Changelog.txt"); Server.SaveAllLevels(); Player[] players = PlayerInfo.Online.Items; @@ -137,6 +138,12 @@ public static void PerformUpdate(bool release) { } } + static void DownloadFile(WebClient client, string url, string dst) { + Logger.Log(LogType.SystemActivity, "Downloading {0} to {1}", + url, Path.GetFileName(dst)); + client.DownloadFile(url, dst); + } + static void DeleteFiles(params string[] paths) { foreach (string path in paths) { AtomicIO.TryDelete(path); } }