This repository has been archived by the owner on Mar 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Showing
5 changed files
with
66 additions
and
15 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
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,43 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Squirrel; | ||
using System.Reflection; | ||
using DeckTracker.LowLevel; | ||
|
||
namespace DeckTracker | ||
{ | ||
public static class UpdateManager | ||
{ | ||
private const string UpdateUrl = "https://github.com/extesy/DeckTracker"; | ||
|
||
public delegate void OnNewVersionHandler(string newVersion); | ||
public static event OnNewVersionHandler OnNewVersion; | ||
|
||
private static async void CheckForUpdate() | ||
{ | ||
try { | ||
string currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(3); | ||
using (var updateManager = await Squirrel.UpdateManager.GitHubUpdateManager(UpdateUrl)) { | ||
var updateInfo = await updateManager.CheckForUpdate(); | ||
string newVersion = updateInfo.FutureReleaseEntry.Version.ToString(); | ||
if (!newVersion.Equals(currentVersion)) { | ||
Logger.LogDebug(Domain.GameType.Eternal, $"Started update to version {newVersion}"); | ||
await updateManager.UpdateApp(); | ||
Logger.LogDebug(Domain.GameType.Eternal, $"Updated to version {newVersion}"); | ||
OnNewVersion?.Invoke(newVersion); | ||
} | ||
} | ||
} catch (Exception e) { | ||
Logger.LogError(e.ToString()); | ||
} | ||
} | ||
|
||
public static async void StartUpdateCheck() | ||
{ | ||
while (true) { | ||
CheckForUpdate(); | ||
await Task.Delay(TimeSpan.FromHours(1.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