Package 업데이트 분리 작업 진행중

This commit is contained in:
2025-08-18 16:24:13 +09:00
parent e46583f725
commit c7aeee4eee
3 changed files with 70 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
@@ -30,7 +31,9 @@ namespace CommonLibrary
} }
public override void Flush() => insideStream.Flush(); public override void Flush() => insideStream.Flush();
public override long Seek(long offset, SeekOrigin origin) => insideStream.Seek(offset, origin); public override long Seek(long offset, SeekOrigin origin) => insideStream.Seek(offset, origin);
public override void SetLength(long value) => insideStream.SetLength(value); public override void SetLength(long value) => insideStream.SetLength(value);
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)
@@ -116,6 +119,62 @@ namespace CommonLibrary
} }
} }
} }
public List<PackList> GetTopLevelItem(string packFileName)
{
List<PackList> packLists = new List<PackList>();
using (ZipArchive archive = ZipFile.OpenRead(packFileName))
{
// 최상위 항목들(폴더/파일명) 추출
var results = new List<PackList>();
var seen = new HashSet<string>(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<T> : IProgress<T> public class BasicProgress<T> : IProgress<T>

View File

@@ -136,17 +136,17 @@ namespace Mitria_Minecraft_Launcher.Updater
CommonLibrary.Log CommonLibrary.Log
.INFO(string.Format("{0}", result == 1 ? "remote is the upper version" : "remote is the lower version")); .INFO(string.Format("{0}", result == 1 ? "remote is the upper version" : "remote is the lower version"));
bool packageInitialization = true; bool packageInitialization = true;
if (thisVersion.Major < remoteVersion.Major || if (thisVersion.Major < remoteVersion.Major || thisVersion.Minor < remoteVersion.Minor)
(thisVersion.Major == remoteVersion.Major && thisVersion.Minor < remoteVersion.Minor))
{ {
packageInitialization = false; CommonLibrary.Log.INFO("[Package] delete it for update.");
CommonLibrary.Log.INFO("[Package] update.");
} }
else 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))); 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(); rootDirectoryInfo.Create();
Log.INFO("[Package] +[D] " + rootDirectoryInfo.FullName); Log.INFO("[Package] +[D] " + rootDirectoryInfo.FullName);
} }
else else if(packageInitialization)
{ {
// 비우기 전에 스크린샷폴더 보존 /screenshots // 비우기 전에 스크린샷폴더 보존 /screenshots
string oldScreenshotsDirectory = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName, "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); downloader.DownloadFile(downloadUrl, targetPath);
Log.INFO("[Package] Download End"); Log.INFO("[Package] Download End");
if (Settings.UserClientVersion.PackageDirectorys != null) if (Settings.UserClientVersion.PackageDirectorys != null)
{ {
foreach (var item in Settings.UserClientVersion.PackageDirectorys) foreach (var item in Settings.UserClientVersion.PackageDirectorys)

View File

@@ -2,10 +2,11 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<StartupObject>Mitria_Minecraft_Updater.Program</StartupObject> <StartupObject>Mitria_Minecraft_Updater.Program</StartupObject>
<AssemblyName>mmu</AssemblyName> <AssemblyName>mmu</AssemblyName>
<DebugType>embedded</DebugType> <DebugType>embedded</DebugType>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>