|
@@ -1,11 +1,4 @@
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.IO;
|
|
|
-using System.IO.Compression;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
-
|
|
|
+using FisTools;
|
|
|
namespace fis.Loader.Handlers
|
|
|
{
|
|
|
internal class FullUpgradeHandler : BaseHandler
|
|
@@ -15,83 +8,7 @@ namespace fis.Loader.Handlers
|
|
|
}
|
|
|
internal override void Execute()
|
|
|
{
|
|
|
- Logger.WriteLine($"Full upgrade");
|
|
|
- KillApp();
|
|
|
- var currentDir = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
-
|
|
|
-
|
|
|
- var fisDir = Directory.GetParent(currentDir)!.Parent!.FullName;
|
|
|
- Logger.WriteLine($"Fis dir is {fisDir}");
|
|
|
- var filesToCopy = Directory.GetFiles(currentDir);
|
|
|
-
|
|
|
- foreach (var file in filesToCopy)
|
|
|
- {
|
|
|
- var ext = Path.GetExtension(file);
|
|
|
- Logger.WriteLine($"File name {file}");
|
|
|
- if (ext != ".zip")
|
|
|
- {
|
|
|
- Logger.WriteLine($"None zip file skipped {file}");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- var fileName = Path.GetFileName(file);
|
|
|
- if (!fileName.Contains("fis_package"))
|
|
|
- {
|
|
|
- Logger.WriteLine($"Zip file skipped {file}");
|
|
|
- continue;
|
|
|
- }
|
|
|
- Logger.WriteLine($"Do extract {file} begin");
|
|
|
- var fileNameWithoutExt = Path.GetFileNameWithoutExtension(file);
|
|
|
- var filePathToSkip = $"{fileNameWithoutExt}/";
|
|
|
- Logger.WriteLine("Begin to extract");
|
|
|
- using (ZipArchive archive = ZipFile.OpenRead(file))
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- var entrys = archive.Entries;
|
|
|
- var fileDirs = entrys.Where(c => c.Name == "");
|
|
|
- var filesEntries = entrys.Where(c => c.Name != "");
|
|
|
- foreach (var dir in fileDirs)
|
|
|
- {
|
|
|
- var entrySubPath = dir.FullName.Replace(filePathToSkip, "");
|
|
|
- if (string.IsNullOrEmpty(entrySubPath))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- string entryPath = Path.Combine(fisDir, entrySubPath);
|
|
|
- if (!Directory.Exists(entryPath))
|
|
|
- {
|
|
|
- Directory.CreateDirectory(entryPath);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- foreach (ZipArchiveEntry fileEntry in filesEntries)
|
|
|
- {
|
|
|
- var entrySubPath = fileEntry.FullName.Replace(filePathToSkip, "");
|
|
|
- string entryPath = Path.Combine(fisDir, entrySubPath);
|
|
|
- if (!fileEntry.Name.Contains("loader.exe"))
|
|
|
- {
|
|
|
- fileEntry.ExtractToFile(entryPath, true);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- Logger.WriteLine($"Extract error {ex}");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- Logger.WriteLine("End to extract");
|
|
|
-
|
|
|
- Logger.WriteLine($"Do extract {file} end");
|
|
|
- Logger.WriteLine($"Do delete {file} begin");
|
|
|
- File.Delete(file);
|
|
|
- Logger.WriteLine($"Do delete {file} end");
|
|
|
- }
|
|
|
- Logger.WriteLine($"Do restart begin");
|
|
|
- new StartHandler().ExecuteWithPath(fisDir);
|
|
|
- Logger.WriteLine($"Do restart end");
|
|
|
+ ToolManager.Instance.UpgradeCenter.ExecuteFullUpgrade(Logger.WriteLine);
|
|
|
}
|
|
|
}
|
|
|
}
|