mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 07:43:31 -07:00
Clean up platform checks in update service
This commit is contained in:
parent
8380e88744
commit
3b3423dd9b
|
|
@ -26,7 +26,7 @@
|
||||||
<PackageReference Include="Material.Avalonia" Version="3.6.0" />
|
<PackageReference Include="Material.Avalonia" Version="3.6.0" />
|
||||||
<PackageReference Include="Material.Icons.Avalonia" Version="2.1.9" />
|
<PackageReference Include="Material.Icons.Avalonia" Version="2.1.9" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
<PackageReference Include="Onova" Version="2.6.11" />
|
<PackageReference Include="Onova" Version="2.6.12" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ namespace DiscordChatExporter.Gui.Services;
|
||||||
|
|
||||||
public class UpdateService(SettingsService settingsService) : IDisposable
|
public class UpdateService(SettingsService settingsService) : IDisposable
|
||||||
{
|
{
|
||||||
private readonly IUpdateManager _updateManager = new UpdateManager(
|
private readonly IUpdateManager? _updateManager = OperatingSystem.IsWindows()
|
||||||
|
? new UpdateManager(
|
||||||
new GithubPackageResolver(
|
new GithubPackageResolver(
|
||||||
"Tyrrrz",
|
"Tyrrrz",
|
||||||
"DiscordChatExporter",
|
"DiscordChatExporter",
|
||||||
|
|
@ -20,7 +21,8 @@ public class UpdateService(SettingsService settingsService) : IDisposable
|
||||||
$"DiscordChatExporter.{RuntimeInformation.RuntimeIdentifier}.zip"
|
$"DiscordChatExporter.{RuntimeInformation.RuntimeIdentifier}.zip"
|
||||||
),
|
),
|
||||||
new ZipPackageExtractor()
|
new ZipPackageExtractor()
|
||||||
);
|
)
|
||||||
|
: null;
|
||||||
|
|
||||||
private Version? _updateVersion;
|
private Version? _updateVersion;
|
||||||
private bool _updatePrepared;
|
private bool _updatePrepared;
|
||||||
|
|
@ -28,6 +30,9 @@ public class UpdateService(SettingsService settingsService) : IDisposable
|
||||||
|
|
||||||
public async ValueTask<Version?> CheckForUpdatesAsync()
|
public async ValueTask<Version?> CheckForUpdatesAsync()
|
||||||
{
|
{
|
||||||
|
if (_updateManager is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
if (!settingsService.IsAutoUpdateEnabled)
|
if (!settingsService.IsAutoUpdateEnabled)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
@ -37,6 +42,9 @@ public class UpdateService(SettingsService settingsService) : IDisposable
|
||||||
|
|
||||||
public async ValueTask PrepareUpdateAsync(Version version)
|
public async ValueTask PrepareUpdateAsync(Version version)
|
||||||
{
|
{
|
||||||
|
if (_updateManager is null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!settingsService.IsAutoUpdateEnabled)
|
if (!settingsService.IsAutoUpdateEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -57,11 +65,10 @@ public class UpdateService(SettingsService settingsService) : IDisposable
|
||||||
|
|
||||||
public void FinalizeUpdate(bool needRestart)
|
public void FinalizeUpdate(bool needRestart)
|
||||||
{
|
{
|
||||||
if (!settingsService.IsAutoUpdateEnabled)
|
if (_updateManager is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Onova only works on Windows currently
|
if (!settingsService.IsAutoUpdateEnabled)
|
||||||
if (!OperatingSystem.IsWindows())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_updateVersion is null || !_updatePrepared || _updaterLaunched)
|
if (_updateVersion is null || !_updatePrepared || _updaterLaunched)
|
||||||
|
|
@ -82,5 +89,5 @@ public class UpdateService(SettingsService settingsService) : IDisposable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() => _updateManager.Dispose();
|
public void Dispose() => _updateManager?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue