diff --git a/CommonLibrary/Packer.cs b/CommonLibrary/Packer.cs index 5df14ff..30bc69b 100644 --- a/CommonLibrary/Packer.cs +++ b/CommonLibrary/Packer.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Linq; @@ -30,7 +31,9 @@ namespace CommonLibrary } public override void Flush() => insideStream.Flush(); + public override long Seek(long offset, SeekOrigin origin) => insideStream.Seek(offset, origin); + public override void SetLength(long value) => insideStream.SetLength(value); public override int Read(byte[] buffer, int offset, int count) @@ -116,6 +119,62 @@ namespace CommonLibrary } } } + + public List GetTopLevelItem(string packFileName) + { + List packLists = new List(); + + using (ZipArchive archive = ZipFile.OpenRead(packFileName)) + { + // 최상위 항목들(폴더/파일명) 추출 + + var results = new List(); + var seen = new HashSet(StringComparer.OrdinalIgnoreCase); + + foreach (var entry in archive.Entries) + { + string path = entry.FullName.Replace('\\', '/'); + if (string.IsNullOrEmpty(path)) continue; + + int firstSlash = path.IndexOf('/'); + + if (firstSlash < 0) + { + // ZIP 루트에 바로 들어있는 항목 + if (string.IsNullOrEmpty(entry.Name)) + { + // 디렉터리 엔트리 + if (seen.Add(path.TrimEnd('/'))) + results.Add(new PackList { IsDirectory = true, Name = path.TrimEnd('/') }); + } + else + { + // 파일 + if (seen.Add(path)) + results.Add(new PackList { IsDirectory = false, Name = path }); + } + } + else + { + // 하위 경로가 있음 → 최상위는 폴더 + string top = path.Substring(0, firstSlash); + if (!string.IsNullOrEmpty(top) && seen.Add(top)) + { + results.Add(new PackList { IsDirectory = true, Name = top }); + } + } + } + + return results; + } + } + + public struct PackList + + { + public bool IsDirectory { get; set; } + public string Name { get; set; } + } } public class BasicProgress : IProgress @@ -132,4 +191,4 @@ namespace CommonLibrary actionHandler(value); } } -} +} \ No newline at end of file diff --git a/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs b/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs index 92e44d6..48bb1fb 100644 --- a/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs +++ b/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs @@ -136,17 +136,17 @@ namespace Mitria_Minecraft_Launcher.Updater CommonLibrary.Log .INFO(string.Format("{0}", result == 1 ? "remote is the upper version" : "remote is the lower version")); + bool packageInitialization = true; - if (thisVersion.Major < remoteVersion.Major || - (thisVersion.Major == remoteVersion.Major && thisVersion.Minor < remoteVersion.Minor)) + if (thisVersion.Major < remoteVersion.Major || thisVersion.Minor < remoteVersion.Minor) { - packageInitialization = false; - CommonLibrary.Log.INFO("[Package] update."); + CommonLibrary.Log.INFO("[Package] delete it for update."); } else { - CommonLibrary.Log.INFO("[Package] delete it for update."); + packageInitialization = false; + CommonLibrary.Log.INFO("[Package] update."); } var rootDirectoryInfo = new System.IO.DirectoryInfo(System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName))); @@ -155,7 +155,7 @@ namespace Mitria_Minecraft_Launcher.Updater rootDirectoryInfo.Create(); Log.INFO("[Package] +[D] " + rootDirectoryInfo.FullName); } - else + else if(packageInitialization) { // 비우기 전에 스크린샷폴더 보존 /screenshots string oldScreenshotsDirectory = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName, "screenshots"); @@ -179,6 +179,8 @@ namespace Mitria_Minecraft_Launcher.Updater downloader.DownloadFile(downloadUrl, targetPath); Log.INFO("[Package] Download End"); + + if (Settings.UserClientVersion.PackageDirectorys != null) { foreach (var item in Settings.UserClientVersion.PackageDirectorys) diff --git a/Mitria_Minecraft_Updater/Mitria_Minecraft_Updater.csproj b/Mitria_Minecraft_Updater/Mitria_Minecraft_Updater.csproj index b29c2f7..be4a0fb 100644 --- a/Mitria_Minecraft_Updater/Mitria_Minecraft_Updater.csproj +++ b/Mitria_Minecraft_Updater/Mitria_Minecraft_Updater.csproj @@ -2,10 +2,11 @@ Exe - net8.0 + netcoreapp3.1 Mitria_Minecraft_Updater.Program mmu embedded + x64