Package 업데이트 분리 작업 진행중
This commit is contained in:
@@ -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<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>
|
||||
|
@@ -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)
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<StartupObject>Mitria_Minecraft_Updater.Program</StartupObject>
|
||||
<AssemblyName>mmu</AssemblyName>
|
||||
<DebugType>embedded</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user