- Recovery
This commit is contained in:
@@ -6,89 +6,86 @@ namespace Mitria_Minecraft_Updater
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
static int nowPosTop;
|
||||
static int nowPosLeft;
|
||||
private static int nowPosTop;
|
||||
private static int nowPosLeft;
|
||||
|
||||
static void Main(string[] args)
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
Settings.LoadConfig();
|
||||
if (args.Length < 1)
|
||||
{
|
||||
HelpMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
var versionType = VersionType.Major;
|
||||
var checkArg = false;
|
||||
|
||||
if (args.Length >= 2)
|
||||
UpdateType? updateType = GetUpdateType(args[0]);
|
||||
|
||||
if( updateType == null)
|
||||
{
|
||||
switch (args[1].ToUpper())
|
||||
HelpMessage();
|
||||
return;
|
||||
}
|
||||
if(updateType == UpdateType.Launcher)
|
||||
{
|
||||
LauncherUpdate();
|
||||
return;
|
||||
}
|
||||
if (args.Length < 3)
|
||||
{
|
||||
HelpMessage();
|
||||
return;
|
||||
}
|
||||
VersionType? versionType = GetVersionType(args[1]);
|
||||
if (versionType == null)
|
||||
{
|
||||
HelpMessage();
|
||||
return;
|
||||
}
|
||||
CommonLibrary.ServerInformation serverInformation = Settings.LoadServerInformation();
|
||||
if(CommonLibrary.Extensions.IsDefault(ref serverInformation))
|
||||
{
|
||||
Console.WriteLine("not found ServerData Location : " + Settings.config.Target + Settings.config.InformationToServer);
|
||||
return;
|
||||
}
|
||||
|
||||
bool serverIs = false;
|
||||
string serverOriginalName = string.Empty;
|
||||
string serverList = string.Empty;
|
||||
foreach (var item in serverInformation.Servers)
|
||||
{
|
||||
serverList += item.ServerName + ", ";
|
||||
if( item.ServerName.ToUpper() == args[2].ToUpper())
|
||||
{
|
||||
case "MAJOR":
|
||||
versionType = VersionType.Major;
|
||||
break;
|
||||
|
||||
case "MINOR":
|
||||
versionType = VersionType.Minor;
|
||||
break;
|
||||
|
||||
case "BUILD":
|
||||
versionType = VersionType.Build;
|
||||
break;
|
||||
|
||||
case "REVISION":
|
||||
versionType = VersionType.Revision;
|
||||
break;
|
||||
|
||||
default:
|
||||
HelpMessage();
|
||||
return;
|
||||
serverIs = true;
|
||||
serverOriginalName = item.ServerName;
|
||||
}
|
||||
|
||||
checkArg = true;
|
||||
}
|
||||
|
||||
switch (args[0].ToUpper())
|
||||
if(!serverIs)
|
||||
{
|
||||
case "LAUNCHER":
|
||||
LauncherUpdate();
|
||||
break;
|
||||
|
||||
case "RUNTIME":
|
||||
if (!checkArg)
|
||||
{
|
||||
HelpMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
RuntimeUpdate(versionType);
|
||||
|
||||
break;
|
||||
|
||||
case "PACKAGE":
|
||||
if (!checkArg)
|
||||
{
|
||||
HelpMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
PackageUpdate(versionType);
|
||||
break;
|
||||
|
||||
case "COMPONENT":
|
||||
if (!checkArg)
|
||||
{
|
||||
HelpMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
ComponentUpdate(versionType);
|
||||
break;
|
||||
|
||||
default:
|
||||
HelpMessage();
|
||||
HelpMessage();
|
||||
if (serverList.Length > 1)
|
||||
{
|
||||
serverList = serverList.Substring(0, serverList.Length - 2);
|
||||
Console.WriteLine(" [ServerList] " + serverList);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch(updateType)
|
||||
{
|
||||
case UpdateType.Runtime:
|
||||
RuntimeUpdate(serverOriginalName, (VersionType)versionType);
|
||||
break;
|
||||
case UpdateType.Package:
|
||||
PackageUpdate(serverOriginalName, (VersionType)versionType);
|
||||
break;
|
||||
case UpdateType.Component:
|
||||
ComponentUpdate(serverOriginalName, (VersionType)versionType);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void HelpMessage()
|
||||
@@ -96,15 +93,15 @@ namespace Mitria_Minecraft_Updater
|
||||
Console.WriteLine("dotnet mmu.dll [option1] [option2]");
|
||||
Console.WriteLine(" [option1] Launcher, Runtime, Package, Component");
|
||||
Console.WriteLine(" [option2] Major, Minor, Build, Revision");
|
||||
Console.WriteLine(" [option3] ServerName");
|
||||
}
|
||||
|
||||
public static void LauncherUpdate()
|
||||
{
|
||||
Settings.LoadConfig();
|
||||
var launcherPatchInformation = Settings.LoadLauncherPatchInformation(); // 런처 패치정보 Load
|
||||
Console.WriteLine("Start Launcher Update");
|
||||
|
||||
var launcherSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source , Settings.config.LauncherSource);
|
||||
|
||||
var launcherSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, Settings.config.LauncherSource);
|
||||
var launcherTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, Settings.config.LauncherUrl);
|
||||
var launcherSourceFile = CommonLibrary.Extensions.PathCombineL(launcherSourceDirectory, Settings.config.LauncherFileName);
|
||||
var launcherTargetFile = CommonLibrary.Extensions.PathCombineL(launcherTargetDirectory, Settings.config.LauncherFileName);
|
||||
@@ -113,13 +110,13 @@ namespace Mitria_Minecraft_Updater
|
||||
|
||||
if (!System.IO.File.Exists(launcherSourceFile))
|
||||
{
|
||||
Console.WriteLine("The source file could not be found.");
|
||||
Console.WriteLine("The source file could not be found. Location : " + launcherSourceFile);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(launcherSourceFile);
|
||||
|
||||
var sourceVersion = new Version(fileVersionInfo.ProductVersion);
|
||||
var sourceVersion = new Version(fileVersionInfo.ProductVersion);
|
||||
|
||||
Version oldVersoin;
|
||||
|
||||
@@ -144,7 +141,7 @@ namespace Mitria_Minecraft_Updater
|
||||
Console.WriteLine("The existing version is higher.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (System.IO.File.Exists(launcherTargetFile))
|
||||
{
|
||||
System.IO.File.Delete(launcherTargetFile);
|
||||
@@ -157,24 +154,21 @@ namespace Mitria_Minecraft_Updater
|
||||
Console.WriteLine("Update Complete");
|
||||
}
|
||||
|
||||
public static void RuntimeUpdate(VersionType versionType)
|
||||
public static void RuntimeUpdate(string serverName, VersionType versionType)
|
||||
{
|
||||
Settings.LoadConfig();
|
||||
var dataPatchInformation = Settings.LoadDataPatchInformation();
|
||||
var dataPatchInformation = Settings.LoadDataPatchInformation(serverName);
|
||||
Console.WriteLine("Start Runtime Update - version " + versionType.ToString());
|
||||
|
||||
|
||||
var runtimeSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, Settings.config.RuntimeSource);
|
||||
var runtimeTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, Settings.config.RuntimeUrl);
|
||||
var runtimeSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source,"Servers" , serverName, Settings.config.RuntimeSource);
|
||||
var runtimeTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target,"Servers", serverName, Settings.config.RuntimeUrl);
|
||||
|
||||
Extensions.DirectoryCheckCrate(runtimeSourceDirectory);
|
||||
Extensions.DirectoryCheckCrate(runtimeTargetDirectory);
|
||||
|
||||
|
||||
// 파일이 하나도 없을경우 조회실패
|
||||
if (System.IO.Directory.GetFiles(runtimeSourceDirectory, "*.*", System.IO.SearchOption.AllDirectories).Length == 0)
|
||||
{
|
||||
Console.WriteLine("The source file could not be found.");
|
||||
Console.WriteLine("The source file could not be found. Location : " + runtimeSourceDirectory );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -198,19 +192,18 @@ namespace Mitria_Minecraft_Updater
|
||||
var newVersion = VersionChange(dataPatchInformation.RuntimeVersion, versionType);
|
||||
Console.WriteLine("update Version : " + dataPatchInformation.RuntimeVersion + " → " + newVersion);
|
||||
dataPatchInformation.RuntimeVersion = newVersion;
|
||||
Settings.SaveDataPatchInformation(dataPatchInformation);
|
||||
Settings.SaveDataPatchInformation(serverName,dataPatchInformation);
|
||||
Console.WriteLine("Update Complete");
|
||||
}
|
||||
|
||||
public static void PackageUpdate(VersionType versionType)
|
||||
public static void PackageUpdate(string serverName, VersionType versionType)
|
||||
{
|
||||
Settings.LoadConfig();
|
||||
var dataPatchInformation = Settings.LoadDataPatchInformation();
|
||||
var dataPatchInformation = Settings.LoadDataPatchInformation(serverName);
|
||||
|
||||
Console.WriteLine("Start Package Update - version " + versionType.ToString());
|
||||
|
||||
var packageSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, Settings.config.PackageSource);
|
||||
var packageTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, Settings.config.PackageUrl);
|
||||
var packageSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, "Servers", serverName, Settings.config.PackageSource);
|
||||
var packageTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, "Servers", serverName, Settings.config.PackageUrl);
|
||||
|
||||
Extensions.DirectoryCheckCrate(packageSourceDirectory);
|
||||
Extensions.DirectoryCheckCrate(packageTargetDirectory);
|
||||
@@ -218,7 +211,7 @@ namespace Mitria_Minecraft_Updater
|
||||
// 파일이 하나도 없을경우 조회실패
|
||||
if (System.IO.Directory.GetFiles(packageSourceDirectory, "*.*", System.IO.SearchOption.AllDirectories).Length == 0)
|
||||
{
|
||||
Console.WriteLine("The source file could not be found.");
|
||||
Console.WriteLine("The source file could not be found. Location : " + packageSourceDirectory );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -229,7 +222,7 @@ namespace Mitria_Minecraft_Updater
|
||||
Packing(packageSourceDirectory, tempFile);
|
||||
|
||||
// 최종 저장 경로 할당
|
||||
var finalTarget = CommonLibrary.Extensions.PathCombineL(packageTargetDirectory , Settings.config.PackageFilename);
|
||||
var finalTarget = CommonLibrary.Extensions.PathCombineL(packageTargetDirectory, Settings.config.PackageFilename);
|
||||
|
||||
// 최종 저장 경로에 이미 파일이 있다면 삭제
|
||||
if (System.IO.File.Exists(finalTarget))
|
||||
@@ -242,7 +235,6 @@ namespace Mitria_Minecraft_Updater
|
||||
|
||||
for (int i = 0; i < directories.Length; i++)
|
||||
{
|
||||
|
||||
directories[i] = System.IO.Path.GetRelativePath(Settings.config.Source, directories[i]);
|
||||
}
|
||||
|
||||
@@ -250,26 +242,25 @@ namespace Mitria_Minecraft_Updater
|
||||
var newVersion = VersionChange(dataPatchInformation.PackageVersion, versionType);
|
||||
Console.WriteLine("Update Version : " + dataPatchInformation.PackageVersion + " → " + newVersion);
|
||||
dataPatchInformation.PackageVersion = newVersion;
|
||||
Settings.SaveDataPatchInformation(dataPatchInformation);
|
||||
Settings.SaveDataPatchInformation(serverName,dataPatchInformation);
|
||||
Console.WriteLine("Update Complete");
|
||||
}
|
||||
|
||||
public static void ComponentUpdate(VersionType versionType)
|
||||
public static void ComponentUpdate(string serverName, VersionType versionType)
|
||||
{
|
||||
Settings.LoadConfig();
|
||||
CommonLibrary.DataPatchInformation dataPatchInformation = Settings.LoadDataPatchInformation();
|
||||
CommonLibrary.DataPatchInformation dataPatchInformation = Settings.LoadDataPatchInformation(serverName);
|
||||
|
||||
Console.WriteLine("Start Component Update - version " + versionType.ToString());
|
||||
|
||||
var componentSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, Settings.config.ComponentSource);
|
||||
var componentTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, Settings.config.ComponentUrl);
|
||||
var componentSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, "Servers", serverName, Settings.config.ComponentSource);
|
||||
var componentTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, "Servers", serverName, Settings.config.ComponentUrl);
|
||||
|
||||
Extensions.DirectoryCheckCrate(componentSourceDirectory);
|
||||
Extensions.DirectoryCheckCrate(componentTargetDirectory);
|
||||
|
||||
if (System.IO.Directory.GetFiles(componentSourceDirectory, "*.*", System.IO.SearchOption.AllDirectories).Length == 0)
|
||||
{
|
||||
Console.WriteLine("The source file could not be found.");
|
||||
Console.WriteLine("The source file could not be found. Location : " + componentSourceDirectory);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -338,7 +329,7 @@ namespace Mitria_Minecraft_Updater
|
||||
{
|
||||
System.IO.File.Delete(targetFileFullPath);
|
||||
System.IO.File.Copy(sourceFileFullPath, targetFileFullPath);
|
||||
Console.Write("Update File : " + oFile);
|
||||
Console.WriteLine("Update File : " + oFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,16 +350,15 @@ namespace Mitria_Minecraft_Updater
|
||||
dataPatchInformation.ComponentDirectorys = sourceDirectorys.ToList();
|
||||
// 파일 디테일
|
||||
|
||||
|
||||
var newVersion = VersionChange(dataPatchInformation.ComponentVersion, versionType);
|
||||
Console.WriteLine("Update Version : " + dataPatchInformation.ComponentVersion + " → " + newVersion);
|
||||
dataPatchInformation.ComponentVersion = newVersion;
|
||||
Settings.SaveDataPatchInformation(dataPatchInformation);
|
||||
Settings.SaveDataPatchInformation(serverName,dataPatchInformation);
|
||||
Console.WriteLine("Update Complete");
|
||||
// 무결성 검사후 업데이트
|
||||
}
|
||||
|
||||
static void Packing(string source, string target)
|
||||
private static void Packing(string source, string target)
|
||||
{
|
||||
if (System.IO.File.Exists(target))
|
||||
{
|
||||
@@ -393,7 +383,7 @@ namespace Mitria_Minecraft_Updater
|
||||
Console.WriteLine("Packing Complite");
|
||||
}
|
||||
|
||||
static string VersionChange(string version, VersionType versionType)
|
||||
private static string VersionChange(string version, VersionType versionType)
|
||||
{
|
||||
var v = Version.Parse(version);
|
||||
|
||||
@@ -419,7 +409,7 @@ namespace Mitria_Minecraft_Updater
|
||||
return v.ToString();
|
||||
}
|
||||
|
||||
static void ProgressChange(double obj)
|
||||
private static void ProgressChange(double obj)
|
||||
{
|
||||
Console.SetCursorPosition(nowPosLeft, nowPosTop);
|
||||
var Progress = (int)(obj * 10);
|
||||
@@ -432,6 +422,66 @@ namespace Mitria_Minecraft_Updater
|
||||
|
||||
Console.Write(" " + $"{obj:P2}");
|
||||
}
|
||||
|
||||
private static UpdateType? GetUpdateType(string data)
|
||||
{
|
||||
UpdateType? updateType;
|
||||
switch (data.ToUpper())
|
||||
{
|
||||
case "LAUNCHER":
|
||||
updateType = UpdateType.Launcher;
|
||||
break;
|
||||
|
||||
case "RUNTIME":
|
||||
updateType = UpdateType.Runtime;
|
||||
break;
|
||||
|
||||
case "PACKAGE":
|
||||
updateType = UpdateType.Package;
|
||||
break;
|
||||
|
||||
case "COMPONENT":
|
||||
updateType = UpdateType.Component;
|
||||
break;
|
||||
|
||||
default:
|
||||
updateType = null;
|
||||
break;
|
||||
}
|
||||
return updateType;
|
||||
|
||||
}
|
||||
private static VersionType? GetVersionType(string data)
|
||||
{
|
||||
|
||||
VersionType? versionType;
|
||||
switch (data.ToUpper())
|
||||
{
|
||||
case "MAJOR":
|
||||
versionType = VersionType.Major;
|
||||
break;
|
||||
|
||||
case "MINOR":
|
||||
versionType = VersionType.Minor;
|
||||
break;
|
||||
|
||||
case "BUILD":
|
||||
versionType = VersionType.Build;
|
||||
break;
|
||||
|
||||
case "REVISION":
|
||||
versionType = VersionType.Revision;
|
||||
break;
|
||||
|
||||
default:
|
||||
versionType = null;
|
||||
break;
|
||||
}
|
||||
return versionType;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
internal enum UpdateType
|
||||
|
Reference in New Issue
Block a user