From a00beb4efcbeefa6097c9bf2ecca7c094254d2d4 Mon Sep 17 00:00:00 2001 From: Crudelis Date: Wed, 21 May 2025 14:47:39 +0900 Subject: [PATCH] =?UTF-8?q?Package=20=EB=B2=84=EC=A0=84=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=9D=BC=20=EB=AC=B4=EC=82=AD=EC=A0=9C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20=EC=8B=9C=EC=9E=91=EC=A0=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Updater/GameUpdateManager.cs | 98 ++++++++++--------- 1 file changed, 54 insertions(+), 44 deletions(-) diff --git a/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs b/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs index afc2d24..92e44d6 100644 --- a/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs +++ b/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs @@ -27,7 +27,7 @@ namespace Mitria_Minecraft_Launcher.Updater // Version File Download CommonLibrary.Log.INFO("download version file."); - var verionData = downloader.DownloadString(CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl,"Servers", Settings.NowProfile.ServerName, Settings.ServerDataPatchInformationFile)); + var verionData = downloader.DownloadString(CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, "Servers", Settings.NowProfile.ServerName, Settings.ServerDataPatchInformationFile)); // Versoin File 받기에 실패하였을때 업데이트 전체 실패처리 if (verionData == string.Empty) @@ -74,7 +74,7 @@ namespace Mitria_Minecraft_Launcher.Updater CommonLibrary.Log.INFO("Runtime delete it for update."); // 런타임 폴더 경로 가져오기 - var rootDirectoryInfo = new System.IO.DirectoryInfo(System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.RuntimeLocation,Settings.NowProfile.ServerName))); + var rootDirectoryInfo = new System.IO.DirectoryInfo(System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.RuntimeLocation, Settings.NowProfile.ServerName))); // 런타임 폴더 삭제후 새로만들기 if (!rootDirectoryInfo.Exists) @@ -124,6 +124,7 @@ namespace Mitria_Minecraft_Launcher.Updater CommonLibrary.Log.INFO("[Package] LocalVersion : " + thisVersion); CommonLibrary.Log.INFO("[Package] RemoteVersion : " + remoteVersion); result = remoteVersion.CompareTo(thisVersion); + //TODO: 만약 Major 버전이 바뀌면 전부삭제, 아니면 있는 폴더면 선별후 삭제 // 1 : 리모트가 큼, 0 : 같음, -1 리모트가 적음 if (result == 0) @@ -133,10 +134,21 @@ namespace Mitria_Minecraft_Launcher.Updater else { CommonLibrary.Log - .INFO(string.Format("{0}", result == 1 ? "remote is the upper version" : "remote is the lower version")); - CommonLibrary.Log.INFO("[Package] delete it for update."); + .INFO(string.Format("{0}", result == 1 ? "remote is the upper version" : "remote is the lower version")); - var rootDirectoryInfo = new System.IO.DirectoryInfo(System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory,Settings.NowProfile.ServerName))); + bool packageInitialization = true; + + if (thisVersion.Major < remoteVersion.Major || + (thisVersion.Major == remoteVersion.Major && thisVersion.Minor < remoteVersion.Minor)) + { + packageInitialization = false; + CommonLibrary.Log.INFO("[Package] update."); + } + else + { + CommonLibrary.Log.INFO("[Package] delete it for update."); + } + var rootDirectoryInfo = new System.IO.DirectoryInfo(System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName))); if (!rootDirectoryInfo.Exists) { @@ -231,7 +243,7 @@ namespace Mitria_Minecraft_Launcher.Updater { // 제거된 폴더 삭제 var resultDirectorys = new List(); - + foreach (var directory in Settings.UserClientVersion.ComponentDirectorys) { if (!dataPatchInformation.ComponentDirectorys.Contains(directory)) @@ -241,7 +253,7 @@ namespace Mitria_Minecraft_Launcher.Updater } foreach (var directory in resultDirectorys) { - var directoryPath = System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory,Settings.NowProfile.ServerName, directory)); + var directoryPath = System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName, directory)); if (System.IO.Directory.Exists(directoryPath)) { @@ -270,7 +282,6 @@ namespace Mitria_Minecraft_Launcher.Updater } } } - } foreach (var directory in dataPatchInformation.ComponentDirectorys) @@ -284,7 +295,6 @@ namespace Mitria_Minecraft_Launcher.Updater } } - var auditFile = new AuditFile(); var localFiles = auditFile.GetLocalFileList(dataPatchInformation.ComponentDirectorys); var removeFiles = auditFile.GetRemoveFiles(localFiles, dataPatchInformation.ComponentList); @@ -294,8 +304,8 @@ namespace Mitria_Minecraft_Launcher.Updater foreach (var fileDetail in removeFiles) { - var filePath = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory,Settings.NowProfile.ServerName, fileDetail.Directory, fileDetail.FileName); - FileInfo fileInfo= new FileInfo(filePath); + var filePath = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName, fileDetail.Directory, fileDetail.FileName); + FileInfo fileInfo = new FileInfo(filePath); fileInfo.IsReadOnly = false; if (fileInfo.Exists) { @@ -309,7 +319,7 @@ namespace Mitria_Minecraft_Launcher.Updater for (int i = 0; i < needFiles.Count; i++) { var url = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, "Servers", Settings.NowProfile.ServerName, dataPatchInformation.ComponentUrl, needFiles[i].Directory, needFiles[i].FileName); - var path = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory,Settings.NowProfile.ServerName, needFiles[i].Directory, needFiles[i].FileName); + var path = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName, needFiles[i].Directory, needFiles[i].FileName); downloader.DownloadFile(url, path); Log.INFO("[Component] +[F] " + path); } @@ -322,10 +332,11 @@ namespace Mitria_Minecraft_Launcher.Updater // 커스텀 폴더, Config #region CustomData + // 삭제된 파일 찾기 string rootCustomPath = System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.CustomDataDirectory, Settings.NowProfile.ServerName)); - if(!System.IO.Directory.Exists(CommonLibrary.Extensions.PathCombineW(rootCustomPath, "config"))) + if (!System.IO.Directory.Exists(CommonLibrary.Extensions.PathCombineW(rootCustomPath, "config"))) { System.IO.Directory.CreateDirectory(CommonLibrary.Extensions.PathCombineW(rootCustomPath, "config")); } @@ -339,14 +350,12 @@ namespace Mitria_Minecraft_Launcher.Updater for (int i = 0; i < files.Count; i++) { files[i] = files[i].Replace(rootCustomPath + '\\', string.Empty); - } foreach (var file in files) { string sourcePath = CommonLibrary.Extensions.PathCombineW(rootCustomPath, file); - string targetPath = CommonLibrary.Extensions.PathCombineW( Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName,file); - + string targetPath = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName, file); if (System.IO.File.Exists(targetPath)) { @@ -354,9 +363,8 @@ namespace Mitria_Minecraft_Launcher.Updater System.IO.FileInfo targetFile = new System.IO.FileInfo(targetPath); if (sourceFile.GetFileHashCode() != targetFile.GetFileHashCode()) { - System.IO.File.Copy(sourcePath, targetPath,true); + System.IO.File.Copy(sourcePath, targetPath, true); Log.INFO("[CustomData] +[F] " + targetPath); - } } else @@ -387,33 +395,35 @@ namespace Mitria_Minecraft_Launcher.Updater GameUpdateManagerMessage?.Invoke(this, e); } } +} - public enum GameUpdateStatus +public enum GameUpdateStatus + +{ + Success, + Fail +} + +public enum GameUpdateManagerMessageType +{ + First, + Second, + Message +} + +public class GameUpdateManagerMessageEventArgs : EventArgs +{ + public GameUpdateManagerMessageType MessageType { get; set; } + public long MinValue { get; set; } + public long MaxValue { get; set; } + public string Message { get; set; } + + public GameUpdateManagerMessageEventArgs(GameUpdateManagerMessageType messageType, long minValue, long maxValue, string message) { - Success, - Fail - } - - public enum GameUpdateManagerMessageType - { - First, - Second, - Message - } - - public class GameUpdateManagerMessageEventArgs : EventArgs - { - public GameUpdateManagerMessageType MessageType { get; set; } - public long MinValue { get; set; } - public long MaxValue { get; set; } - public string Message { get; set; } - - public GameUpdateManagerMessageEventArgs(GameUpdateManagerMessageType messageType, long minValue, long maxValue, string message) - { - MessageType = messageType; - MinValue = minValue; - MaxValue = maxValue; - Message = message; - } + MessageType = messageType; + MinValue = minValue; + MaxValue = maxValue; + Message = message; } +} } \ No newline at end of file