mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2024-09-19 20:28:46 -04:00
Don't crash when update fails
This commit is contained in:
parent
656e5a5b0d
commit
4540134a98
1 changed files with 33 additions and 12 deletions
|
@ -26,14 +26,22 @@ namespace DiscordChatExporter.Core.Services
|
||||||
return null;
|
return null;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Remove some junk left over from last update
|
try
|
||||||
_updateManager.Cleanup();
|
{
|
||||||
|
// Remove some junk left over from last update
|
||||||
|
_updateManager.Cleanup();
|
||||||
|
|
||||||
// Check for updates
|
// Check for updates
|
||||||
var check = await _updateManager.CheckForUpdatesAsync();
|
var check = await _updateManager.CheckForUpdatesAsync();
|
||||||
|
|
||||||
// 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()
|
||||||
|
@ -41,8 +49,15 @@ namespace DiscordChatExporter.Core.Services
|
||||||
if (_lastVersion == null)
|
if (_lastVersion == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Download and prepare update
|
try
|
||||||
await _updateManager.PreparePackageAsync(_lastVersion);
|
{
|
||||||
|
// Download and prepare update
|
||||||
|
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;
|
||||||
|
|
||||||
// Enqueue an update
|
try
|
||||||
await _updateManager.EnqueueApplyPackageAsync(_lastVersion, restart);
|
{
|
||||||
|
// Enqueue an update
|
||||||
_applied = true;
|
await _updateManager.EnqueueApplyPackageAsync(_lastVersion, restart);
|
||||||
|
_applied = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// It's okay for update to fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue