|
|
@ -1,5 +1,6 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using DiscordChatExporter.Core.Services;
|
|
|
|
using Onova;
|
|
|
|
using Onova;
|
|
|
|
using Onova.Exceptions;
|
|
|
|
using Onova.Exceptions;
|
|
|
|
using Onova.Services;
|
|
|
|
using Onova.Services;
|
|
|
@ -12,17 +13,30 @@ namespace DiscordChatExporter.Gui.Services
|
|
|
|
new GithubPackageResolver("Tyrrrz", "DiscordChatExporter", "DiscordChatExporter.zip"),
|
|
|
|
new GithubPackageResolver("Tyrrrz", "DiscordChatExporter", "DiscordChatExporter.zip"),
|
|
|
|
new ZipPackageExtractor());
|
|
|
|
new ZipPackageExtractor());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly SettingsService _settingsService;
|
|
|
|
|
|
|
|
|
|
|
|
private Version? _updateVersion;
|
|
|
|
private Version? _updateVersion;
|
|
|
|
private bool _updaterLaunched;
|
|
|
|
private bool _updaterLaunched;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UpdateService(SettingsService settingsService)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_settingsService = settingsService;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<Version?> CheckForUpdatesAsync()
|
|
|
|
public async Task<Version?> CheckForUpdatesAsync()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!_settingsService.IsAutoUpdateEnabled)
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
var check = await _updateManager.CheckForUpdatesAsync();
|
|
|
|
var check = await _updateManager.CheckForUpdatesAsync();
|
|
|
|
return check.CanUpdate ? check.LastVersion : null;
|
|
|
|
return check.CanUpdate ? check.LastVersion : null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task PrepareUpdateAsync(Version version)
|
|
|
|
public async Task PrepareUpdateAsync(Version version)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!_settingsService.IsAutoUpdateEnabled)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await _updateManager.PrepareUpdateAsync(_updateVersion = version);
|
|
|
|
await _updateManager.PrepareUpdateAsync(_updateVersion = version);
|
|
|
@ -39,13 +53,15 @@ namespace DiscordChatExporter.Gui.Services
|
|
|
|
|
|
|
|
|
|
|
|
public void FinalizeUpdate(bool needRestart)
|
|
|
|
public void FinalizeUpdate(bool needRestart)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
if (!_settingsService.IsAutoUpdateEnabled)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_updateVersion == null || _updaterLaunched)
|
|
|
|
if (_updateVersion == null || _updaterLaunched)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
_updateManager.LaunchUpdater(_updateVersion, needRestart);
|
|
|
|
_updateManager.LaunchUpdater(_updateVersion, needRestart);
|
|
|
|
|
|
|
|
|
|
|
|
_updaterLaunched = true;
|
|
|
|
_updaterLaunched = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (UpdaterAlreadyLaunchedException)
|
|
|
|
catch (UpdaterAlreadyLaunchedException)
|
|
|
|