패키지 업데이트 분리 작업
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -55,6 +56,38 @@ namespace Mitria_Minecraft_Launcher
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DeleteFile(string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.SetAttributes(filePath, FileAttributes.Normal); // 읽기 전용 제거
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("파일 삭제 실패: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DeleteDirectory(string dirPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 하위 파일 속성 변경 및 삭제
|
||||||
|
foreach (string file in Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
File.SetAttributes(file, FileAttributes.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 디렉터리 삭제 (재귀적)
|
||||||
|
Directory.Delete(dirPath, true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("디렉터리 삭제 실패: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string ApplyExcuteCommand(ExcuteArgument excuteArgument)
|
public static string ApplyExcuteCommand(ExcuteArgument excuteArgument)
|
||||||
{
|
{
|
||||||
string command = excuteArgument.Argument;
|
string command = excuteArgument.Argument;
|
||||||
@@ -80,11 +113,11 @@ namespace Mitria_Minecraft_Launcher
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static bool IsDefault<T>(ref this T data) where T : struct
|
public static bool IsDefault<T>(ref this T data) where T : struct
|
||||||
{
|
{
|
||||||
return default(T).Equals(data);
|
return default(T).Equals(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string UnitSeparator(this long value)
|
public static string UnitSeparator(this long value)
|
||||||
{
|
{
|
||||||
return string.Format("{0:#,0}", (object)value);
|
return string.Format("{0:#,0}", (object)value);
|
||||||
@@ -94,6 +127,7 @@ namespace Mitria_Minecraft_Launcher
|
|||||||
{
|
{
|
||||||
return string.Format("{0:#,0}", (object)value);
|
return string.Format("{0:#,0}", (object)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetFileHashCode(this FileInfo file)
|
public static string GetFileHashCode(this FileInfo file)
|
||||||
{
|
{
|
||||||
using (MD5 md5 = MD5.Create())
|
using (MD5 md5 = MD5.Create())
|
||||||
|
@@ -148,6 +148,15 @@ namespace Mitria_Minecraft_Launcher.Updater
|
|||||||
packageInitialization = false;
|
packageInitialization = false;
|
||||||
CommonLibrary.Log.INFO("[Package] update.");
|
CommonLibrary.Log.INFO("[Package] update.");
|
||||||
}
|
}
|
||||||
|
// 패키지 다운로드
|
||||||
|
var downloadUrl = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, "Servers", Settings.NowProfile.ServerName, dataPatchInformation.PackageUrl, dataPatchInformation.PackageFileName);
|
||||||
|
var targetPath = System.IO.Path.Combine(tempDirectory, dataPatchInformation.PackageFileName);
|
||||||
|
GameUpdateManagerMessage(this, new GameUpdateManagerMessageEventArgs(GameUpdateManagerMessageType.First, 5, 9, "[5/9] Package Download"));
|
||||||
|
Log.INFO("[Package] Download Start");
|
||||||
|
downloader.DownloadFile(downloadUrl, targetPath);
|
||||||
|
Log.INFO("[Package] Download End");
|
||||||
|
|
||||||
|
|
||||||
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)));
|
||||||
|
|
||||||
if (!rootDirectoryInfo.Exists)
|
if (!rootDirectoryInfo.Exists)
|
||||||
@@ -157,6 +166,7 @@ namespace Mitria_Minecraft_Launcher.Updater
|
|||||||
}
|
}
|
||||||
else if(packageInitialization)
|
else if(packageInitialization)
|
||||||
{
|
{
|
||||||
|
Log.INFO("[Package] Empty GameDirectory Start");
|
||||||
// 비우기 전에 스크린샷폴더 보존 /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");
|
||||||
string newScreenshotsDirectory = System.IO.Path.GetFullPath("screenshots_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
|
string newScreenshotsDirectory = System.IO.Path.GetFullPath("screenshots_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
|
||||||
@@ -171,16 +181,32 @@ namespace Mitria_Minecraft_Launcher.Updater
|
|||||||
Extensions.EmptyDirectory(rootDirectoryInfo.FullName);
|
Extensions.EmptyDirectory(rootDirectoryInfo.FullName);
|
||||||
Log.INFO("[Package] Empty GameDirectory");
|
Log.INFO("[Package] Empty GameDirectory");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
var downloadUrl = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, "Servers", Settings.NowProfile.ServerName, dataPatchInformation.PackageUrl, dataPatchInformation.PackageFileName);
|
{
|
||||||
var targetPath = System.IO.Path.Combine(tempDirectory, dataPatchInformation.PackageFileName);
|
Log.INFO("[Package] Partial Clean GameDirectory Start");
|
||||||
GameUpdateManagerMessage(this, new GameUpdateManagerMessageEventArgs(GameUpdateManagerMessageType.First, 5, 9, "[5/9] Package Download"));
|
var tempPacker = new ProgressPacker();
|
||||||
Log.INFO("[Package] Download Start");
|
var list = tempPacker.GetTopLevelItem(targetPath);
|
||||||
downloader.DownloadFile(downloadUrl, targetPath);
|
// 리스트에 있는 디렉토리와 파일 삭제
|
||||||
Log.INFO("[Package] Download End");
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
string target = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName, item.Name);
|
||||||
|
if (item.IsDirectory)
|
||||||
|
{
|
||||||
|
Extensions.DeleteDirectory(target);
|
||||||
|
Log.INFO("[Package] -[D] " + target);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Extensions.DeleteFile(target);
|
||||||
|
Log.INFO("[Package] -[F] " + target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.INFO("[Package] Partial Clean GameDirectory 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)
|
||||||
|
Reference in New Issue
Block a user