Apply same refactoring to launcher
This commit is contained in:
parent
40442c6f8b
commit
2c804375fe
1 changed files with 17 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ using Semver;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
|
@ -32,9 +33,15 @@ namespace LANCommander.Launcher.Services
|
|||
{
|
||||
var settings = SettingService.GetSettings();
|
||||
|
||||
Logger?.LogInformation("Updating launcher to v{Version}", version);
|
||||
Logger?.LogInformation("Downloading launcher v{Version}", version);
|
||||
|
||||
await Client.Launcher.DownloadAsync(Path.Combine(settings.Updates.StoragePath, $"{version}.zip"));
|
||||
string path = Path.Combine(settings.Updates.StoragePath, $"{version}.zip");
|
||||
|
||||
await Client.Launcher.DownloadAsync(path);
|
||||
|
||||
Logger?.LogInformation("Update version {Version} has been downloaded", version);
|
||||
|
||||
Logger?.LogInformation("New autoupdater is being extracted");
|
||||
|
||||
string processExecutable = String.Empty;
|
||||
|
||||
|
|
@ -43,6 +50,14 @@ namespace LANCommander.Launcher.Services
|
|||
else if (File.Exists("LANCommander.AutoUpdater"))
|
||||
processExecutable = "LANCommander.AutoUpdater";
|
||||
|
||||
using (ZipArchive archive = ZipFile.OpenRead(path))
|
||||
{
|
||||
foreach (ZipArchiveEntry entry in archive.Entries.Where(e => e.FullName == processExecutable))
|
||||
{
|
||||
entry.ExtractToFile(Path.Combine(processExecutable, entry.FullName));
|
||||
}
|
||||
}
|
||||
|
||||
var process = new ProcessStartInfo();
|
||||
|
||||
process.FileName = processExecutable;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue