-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tensei
committed
Jun 1, 2021
1 parent
60e1054
commit 7ae1cda
Showing
4 changed files
with
149 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Onova; | ||
using Onova.Models; | ||
using Onova.Services; | ||
|
||
namespace Anidow.Helpers | ||
{ | ||
public class UpdateManager | ||
{ | ||
private readonly Onova.UpdateManager _updateManager; | ||
|
||
public UpdateManager(HttpClient httpClient) | ||
{ | ||
var selfContained = false; | ||
#if SELF_CONTAINED && RELEASE | ||
selfContained = true; | ||
#endif | ||
_updateManager = new Onova.UpdateManager( | ||
AssemblyMetadata.FromAssembly( | ||
Assembly.GetEntryAssembly(), | ||
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName), | ||
new GithubPackageResolver( | ||
httpClient, | ||
"MemeLabs", | ||
"Anidow", | ||
selfContained ? "anidow-full.zip" : "anidow.zip"), | ||
new ZipPackageExtractor()); | ||
|
||
} | ||
|
||
public async Task<(CheckForUpdatesResult, bool)> HasUpdate() | ||
{ | ||
var check = await _updateManager.CheckForUpdatesAsync(); | ||
if (!check.CanUpdate || check.LastVersion == null) | ||
{ | ||
return (null, false); | ||
} | ||
|
||
return (check, true); | ||
} | ||
|
||
public async Task Update(CheckForUpdatesResult check) | ||
{ | ||
|
||
// Prepare the latest update | ||
await _updateManager.PrepareUpdateAsync(check.LastVersion); | ||
|
||
// Launch updater and exit | ||
_updateManager.LaunchUpdater(check.LastVersion); | ||
|
||
Environment.Exit(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters