Update Module
- 백신 회피를 위한 런처 수정
This commit is contained in:
@@ -114,13 +114,19 @@ namespace CommonLibrary
|
|||||||
{
|
{
|
||||||
using (Stream outputStream = File.OpenWrite(fileName))
|
using (Stream outputStream = File.OpenWrite(fileName))
|
||||||
{
|
{
|
||||||
|
|
||||||
Stream progressStream = new ProgressStream(outputStream, null,
|
Stream progressStream = new ProgressStream(outputStream, null,
|
||||||
new BasicProgress<int>(i =>
|
new BasicProgress<int>(i =>
|
||||||
{
|
{
|
||||||
currentBytes += i;
|
currentBytes += i;
|
||||||
|
if (progress != null)
|
||||||
|
{
|
||||||
progress.Report(currentBytes / totalBytes);
|
progress.Report(currentBytes / totalBytes);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
inputStream.CopyTo(progressStream);
|
inputStream.CopyTo(progressStream);
|
||||||
|
|
||||||
}
|
}
|
||||||
File.SetLastWriteTime(fileName, entry.LastWriteTime.LocalDateTime);
|
File.SetLastWriteTime(fileName, entry.LastWriteTime.LocalDateTime);
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using CommonLibrary;
|
using CommonLibrary;
|
||||||
namespace Mitria_Minecraft_Launcher.Updater
|
namespace Mitria_Minecraft_Launcher.Updater
|
||||||
@@ -22,6 +23,9 @@ namespace Mitria_Minecraft_Launcher.Updater
|
|||||||
CommonLibrary.Log.INFO("Launcher Version : " + thisVersion);
|
CommonLibrary.Log.INFO("Launcher Version : " + thisVersion);
|
||||||
CommonLibrary.Log.INFO("Remote Launcher Version : " + remoteVersion);
|
CommonLibrary.Log.INFO("Remote Launcher Version : " + remoteVersion);
|
||||||
int result = remoteVersion.CompareTo(thisVersion);
|
int result = remoteVersion.CompareTo(thisVersion);
|
||||||
|
#if DEBUG
|
||||||
|
result =1;
|
||||||
|
#endif
|
||||||
if (result <= 0)
|
if (result <= 0)
|
||||||
{
|
{
|
||||||
CommonLibrary.Log.INFO("Version Same");
|
CommonLibrary.Log.INFO("Version Same");
|
||||||
@@ -37,13 +41,24 @@ namespace Mitria_Minecraft_Launcher.Updater
|
|||||||
}
|
}
|
||||||
|
|
||||||
string downloadUrl = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, launcherPatchInformation.LauncherUrl, launcherPatchInformation.LauncherFileName);
|
string downloadUrl = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, launcherPatchInformation.LauncherUrl, launcherPatchInformation.LauncherFileName);
|
||||||
string newLauncherFile = CommonLibrary.Extensions.PathCombineW(tempDirectory, launcherPatchInformation.LauncherFileName);
|
string launcherPackFile = CommonLibrary.Extensions.PathCombineW(tempDirectory, launcherPatchInformation.LauncherFileName);
|
||||||
downloader.DownloadFile(downloadUrl, newLauncherFile);
|
downloader.DownloadFile(downloadUrl, launcherPackFile);
|
||||||
string launcherFile = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
|
||||||
string oldLauncherFile = CommonLibrary.Extensions.PathCombineW(tempDirectory, System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + "_old");
|
|
||||||
|
|
||||||
|
string launcherFile = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||||
|
string launcherPath = System.IO.Path.GetDirectoryName(launcherFile);
|
||||||
|
|
||||||
|
// 기존 파일 파일명 변경후 temp 디렉토리로 이전
|
||||||
|
string oldLauncherFile = CommonLibrary.Extensions.PathCombineW(tempDirectory, System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + "_old");
|
||||||
System.IO.File.Move(launcherFile, oldLauncherFile);
|
System.IO.File.Move(launcherFile, oldLauncherFile);
|
||||||
System.IO.File.Move(newLauncherFile, launcherFile);
|
|
||||||
|
// 언패킹 과정
|
||||||
|
var progressPacker = new ProgressPacker();
|
||||||
|
|
||||||
|
Log.INFO("[Launcher] Unpack Start");
|
||||||
|
progressPacker.UnPack(launcherPackFile, launcherPath, null);
|
||||||
|
Log.INFO("[Launcher] Unpack Done");
|
||||||
|
|
||||||
|
//System.IO.File.Move(newLauncherFile, launcherFile);
|
||||||
return LauncherUpdateStatus.Update;
|
return LauncherUpdateStatus.Update;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Mitria_Minecraft_Updater
|
namespace Mitria_Minecraft_Updater
|
||||||
{
|
{
|
||||||
@@ -50,14 +51,15 @@ namespace Mitria_Minecraft_Updater
|
|||||||
|
|
||||||
bool serverIs = false;
|
bool serverIs = false;
|
||||||
string serverOriginalName = string.Empty;
|
string serverOriginalName = string.Empty;
|
||||||
string serverList = string.Empty;
|
StringBuilder serverList = new StringBuilder();
|
||||||
foreach (var item in serverInformation.Servers)
|
foreach (var serverName in serverInformation.Servers.Select(x => x.ServerName))
|
||||||
{
|
{
|
||||||
serverList += item.ServerName + ", ";
|
serverList.Append(serverName);
|
||||||
if( item.ServerName.ToUpper() == args[2].ToUpper())
|
serverList.Append(", ");
|
||||||
|
if(serverName.ToUpper() == args[2].ToUpper())
|
||||||
{
|
{
|
||||||
serverIs = true;
|
serverIs = true;
|
||||||
serverOriginalName = item.ServerName;
|
serverOriginalName = serverName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!serverIs)
|
if(!serverIs)
|
||||||
@@ -65,8 +67,8 @@ namespace Mitria_Minecraft_Updater
|
|||||||
HelpMessage();
|
HelpMessage();
|
||||||
if (serverList.Length > 1)
|
if (serverList.Length > 1)
|
||||||
{
|
{
|
||||||
serverList = serverList.Substring(0, serverList.Length - 2);
|
serverList.Remove(serverList.Length - 2, 2);
|
||||||
Console.WriteLine(" [ServerList] " + serverList);
|
Console.WriteLine(" [ServerList] " + serverList.ToString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,12 +105,12 @@ namespace Mitria_Minecraft_Updater
|
|||||||
|
|
||||||
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 launcherTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, Settings.config.LauncherUrl);
|
||||||
var launcherSourceFile = CommonLibrary.Extensions.PathCombineL(launcherSourceDirectory, Settings.config.LauncherFileName);
|
var launcherSourceFile = CommonLibrary.Extensions.PathCombineL(launcherSourceDirectory, Settings.config.LauncherSourceFileName);
|
||||||
var launcherTargetFile = CommonLibrary.Extensions.PathCombineL(launcherTargetDirectory, Settings.config.LauncherFileName);
|
var launcherTargetFile = CommonLibrary.Extensions.PathCombineL(launcherTargetDirectory, Settings.config.LauncherFileName);
|
||||||
Extensions.DirectoryCheckCrate(launcherSourceDirectory);
|
Extensions.DirectoryCheckCrate(launcherSourceDirectory);
|
||||||
Extensions.DirectoryCheckCrate(launcherTargetDirectory);
|
Extensions.DirectoryCheckCrate(launcherTargetDirectory);
|
||||||
|
|
||||||
if (!System.IO.File.Exists(launcherSourceFile))
|
if (!System.IO.File.Exists(launcherSourceFile)) // 런처 소스 파일이 있는지 확인
|
||||||
{
|
{
|
||||||
Console.WriteLine("The source file could not be found. Location : " + launcherSourceFile);
|
Console.WriteLine("The source file could not be found. Location : " + launcherSourceFile);
|
||||||
return;
|
return;
|
||||||
@@ -147,7 +149,12 @@ namespace Mitria_Minecraft_Updater
|
|||||||
System.IO.File.Delete(launcherTargetFile);
|
System.IO.File.Delete(launcherTargetFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.IO.File.Copy(launcherSourceFile, launcherTargetFile);
|
var tempFile = "launcher.temp";
|
||||||
|
|
||||||
|
// Pakcing 작업 시작
|
||||||
|
Packing(launcherSourceDirectory, tempFile);
|
||||||
|
|
||||||
|
System.IO.File.Move(tempFile, launcherTargetFile);
|
||||||
Console.WriteLine("update Version : " + launcherPatchInformation.Version + " → " + sourceVersion);
|
Console.WriteLine("update Version : " + launcherPatchInformation.Version + " → " + sourceVersion);
|
||||||
launcherPatchInformation.Version = sourceVersion.ToString();
|
launcherPatchInformation.Version = sourceVersion.ToString();
|
||||||
Settings.SaveLauncherPatchInformation(launcherPatchInformation);
|
Settings.SaveLauncherPatchInformation(launcherPatchInformation);
|
||||||
@@ -179,7 +186,7 @@ namespace Mitria_Minecraft_Updater
|
|||||||
Packing(runtimeSourceDirectory, tempFile);
|
Packing(runtimeSourceDirectory, tempFile);
|
||||||
|
|
||||||
// 최종 저장 경로 할당
|
// 최종 저장 경로 할당
|
||||||
var finalTarget = CommonLibrary.Extensions.PathCombineL(runtimeTargetDirectory, Settings.config.RuntimeFilename);
|
var finalTarget = CommonLibrary.Extensions.PathCombineL(runtimeTargetDirectory, Settings.config.RuntimeFileName);
|
||||||
|
|
||||||
// 최종 저장 경로에 이미 파일이 있다면 삭제
|
// 최종 저장 경로에 이미 파일이 있다면 삭제
|
||||||
if (System.IO.File.Exists(finalTarget))
|
if (System.IO.File.Exists(finalTarget))
|
||||||
@@ -222,7 +229,7 @@ namespace Mitria_Minecraft_Updater
|
|||||||
Packing(packageSourceDirectory, tempFile);
|
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))
|
if (System.IO.File.Exists(finalTarget))
|
||||||
|
@@ -23,13 +23,14 @@ namespace Mitria_Minecraft_Updater
|
|||||||
|
|
||||||
config.LauncherSource = "/Launcher";
|
config.LauncherSource = "/Launcher";
|
||||||
config.LauncherUrl = "/Launcher";
|
config.LauncherUrl = "/Launcher";
|
||||||
config.LauncherFileName = "MitriaMLauncher.exe";
|
config.LauncherSourceFileName = "MitriaMLauncher.exe";
|
||||||
|
config.LauncherFileName = "MitriaMLauncher.pack";
|
||||||
config.RuntimeSource = "/Runtime";
|
config.RuntimeSource = "/Runtime";
|
||||||
config.RuntimeUrl = "/Data/Runtime";
|
config.RuntimeUrl = "/Data/Runtime";
|
||||||
config.RuntimeFilename = "Runtime.pack";
|
config.RuntimeFileName = "Runtime.pack";
|
||||||
config.PackageSource = "/Package";
|
config.PackageSource = "/Package";
|
||||||
config.PackageUrl = "/Data/Package";
|
config.PackageUrl = "/Data/Package";
|
||||||
config.PackageFilename = "Package.pack";
|
config.PackageFileName = "Package.pack";
|
||||||
config.ComponentSource = "/Component";
|
config.ComponentSource = "/Component";
|
||||||
config.ComponentUrl = "/Data/Component";
|
config.ComponentUrl = "/Data/Component";
|
||||||
}
|
}
|
||||||
@@ -111,9 +112,9 @@ namespace Mitria_Minecraft_Updater
|
|||||||
dataPatchInformation.ComponentList = new System.Collections.Generic.List<CommonLibrary.FileDetail>();
|
dataPatchInformation.ComponentList = new System.Collections.Generic.List<CommonLibrary.FileDetail>();
|
||||||
}
|
}
|
||||||
dataPatchInformation.RuntimeUrl = config.RuntimeUrl;
|
dataPatchInformation.RuntimeUrl = config.RuntimeUrl;
|
||||||
dataPatchInformation.RuntimeFileName = config.RuntimeFilename;
|
dataPatchInformation.RuntimeFileName = config.RuntimeFileName;
|
||||||
dataPatchInformation.PackageUrl = config.PackageUrl;
|
dataPatchInformation.PackageUrl = config.PackageUrl;
|
||||||
dataPatchInformation.PackageFileName = config.PackageFilename;
|
dataPatchInformation.PackageFileName = config.PackageFileName;
|
||||||
dataPatchInformation.ComponentUrl = config.ComponentUrl;
|
dataPatchInformation.ComponentUrl = config.ComponentUrl;
|
||||||
|
|
||||||
return dataPatchInformation;
|
return dataPatchInformation;
|
||||||
@@ -142,15 +143,16 @@ namespace Mitria_Minecraft_Updater
|
|||||||
public string InformationToServer { get; set; }
|
public string InformationToServer { get; set; }
|
||||||
public string LauncherSource { get; set; } // {Source}/Launcher
|
public string LauncherSource { get; set; } // {Source}/Launcher
|
||||||
public string LauncherUrl { get; set; } // {Target}/Launcher
|
public string LauncherUrl { get; set; } // {Target}/Launcher
|
||||||
|
public string LauncherSourceFileName { get; set; }
|
||||||
public string LauncherFileName { get; set; } // 런처 파일이름
|
public string LauncherFileName { get; set; } // 런처 파일이름
|
||||||
|
|
||||||
public string RuntimeSource { get; set; } // {Source}/Runtime
|
public string RuntimeSource { get; set; } // {Source}/Runtime
|
||||||
public string RuntimeUrl { get; set; } // {Target}/Runtime
|
public string RuntimeUrl { get; set; } // {Target}/Runtime
|
||||||
public string RuntimeFilename { get; set; } // Runtime.pack
|
public string RuntimeFileName { get; set; } // Runtime.pack
|
||||||
|
|
||||||
public string PackageSource { get; set; } // {Source}/Package
|
public string PackageSource { get; set; } // {Source}/Package
|
||||||
public string PackageUrl { get; set; } // {Target}/Package
|
public string PackageUrl { get; set; } // {Target}/Package
|
||||||
public string PackageFilename { get; set; } // Package.pack
|
public string PackageFileName { get; set; } // Package.pack
|
||||||
|
|
||||||
public string ComponentSource { get; set; } // {Source}/GameFile
|
public string ComponentSource { get; set; } // {Source}/GameFile
|
||||||
public string ComponentUrl { get; set; } // {Target}/GameFile
|
public string ComponentUrl { get; set; } // {Target}/GameFile
|
||||||
|
Reference in New Issue
Block a user