Don't crash when update fails

pull/37/head
Alexey Golub 7 years ago
parent 656e5a5b0d
commit 4540134a98

@ -26,6 +26,8 @@ namespace DiscordChatExporter.Core.Services
return null; return null;
#endif #endif
try
{
// Remove some junk left over from last update // Remove some junk left over from last update
_updateManager.Cleanup(); _updateManager.Cleanup();
@ -35,15 +37,28 @@ namespace DiscordChatExporter.Core.Services
// Return latest version or null if running latest version already // Return latest version or null if running latest version already
return check.CanUpdate ? _lastVersion = check.LastVersion : null; return check.CanUpdate ? _lastVersion = check.LastVersion : null;
} }
catch
{
// It's okay for update to fail
return null;
}
}
public async Task PrepareUpdateAsync() public async Task PrepareUpdateAsync()
{ {
if (_lastVersion == null) if (_lastVersion == null)
return; return;
try
{
// Download and prepare update // Download and prepare update
await _updateManager.PreparePackageAsync(_lastVersion); await _updateManager.PreparePackageAsync(_lastVersion);
} }
catch
{
// It's okay for update to fail
}
}
public async Task ApplyUpdateAsync(bool restart = true) public async Task ApplyUpdateAsync(bool restart = true)
{ {
@ -52,10 +67,16 @@ namespace DiscordChatExporter.Core.Services
if (_applied) if (_applied)
return; return;
try
{
// Enqueue an update // Enqueue an update
await _updateManager.EnqueueApplyPackageAsync(_lastVersion, restart); await _updateManager.EnqueueApplyPackageAsync(_lastVersion, restart);
_applied = true; _applied = true;
} }
catch
{
// It's okay for update to fail
}
}
} }
} }
Loading…
Cancel
Save