Hash: SHA256 RSL 2.4.3 = Moved nouns.txt library to a more suitable location. HFP -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEKjgtlwMyrpVu4TGfx/Rql1VoczcFAmD4T5kACgkQx/Rql1Vo czd9Ew/+LvPnoSuNl3ynFRAjTs8Yo1r2FCY82UfWLLddYTc4waH4s2HZQkUyFBGo emkvZUa/TZuYGzNLAB4JpPDYYONyF2LmOx8z0Pwtp1+RoEJbGe7WsZa3oF+PQ2AU +1+hE0u8RW546uaGdzyToX3N5JnPAA2MctG0+3X5J+k8C+CHWgMJyoDnoz62b2Qb gER2HZMBlrebJwSJto+tKeLRDk2FI4UmQDu2CQpvlwkQMwa98ORRrulaO4LOEH3I z5S6WyxlcF0Cy4dwD5PVsx4YTHn7Rjy9HHniMYe+vv7LQOz6w+DZZQv6x1BZ2xSF ZqS76T3x5XAVpcH2JX7gce7dTFVpft/P/C/vOVAa8E2pUp3stuUFoIyVoeWPwgvJ 3wkJFeoG4umlLQZY934Mb6Hb2tu38xlcQd/xsO3aZRPUOZBuYMcbpf8V7qv7f+p+ YDSXwI92ostB3RNkXlUy2onSWrXoLQF70lq3zaNcUeyQt6HILc80h1pXC6VWnITz RRH9ojt6CWLyzIXKgqdKWKVJJQ5GIR0YITk4kMyGqM/CP3pUPCUKPAVbWK4ajoGA 1A2JBniQwYmCj+vkfQDpwkacK3zmYy/JRpTYdyj7BuOXjGnPpberjdd+jpgGBRCH IeOpD/kmWaKm5lH1KmEOPGe86bhpQstOba7EsiBM4/x6QpoqVOU= =yWnO -----END PGP SIGNATURE-----
73 lines
2.9 KiB
C#
73 lines
2.9 KiB
C#
using System;
|
|
using System.Text;
|
|
using System.Diagnostics;
|
|
using JR.Utils.GUI.Forms;
|
|
using System.Net;
|
|
using System.Windows.Forms;
|
|
using System.Net.Http;
|
|
using System.IO;
|
|
using AndroidSideloader;
|
|
|
|
namespace AndroidSideloader
|
|
{
|
|
class Updater
|
|
{
|
|
public static string AppName { get; set; }
|
|
public static string Repostory { get; set; }
|
|
private static string RawGitHubUrl;
|
|
private static string GitHubUrl;
|
|
|
|
static readonly public string LocalVersion = "2.4.3";
|
|
public static string currentVersion = string.Empty;
|
|
public static string changelog = string.Empty;
|
|
|
|
//Check if there is a new version of the sideloader
|
|
private static bool IsUpdateAvailable()
|
|
{
|
|
HttpClient client = new HttpClient();
|
|
try
|
|
{
|
|
currentVersion = client.GetStringAsync($"{RawGitHubUrl}/master/version").Result;
|
|
changelog = client.GetStringAsync($"{RawGitHubUrl}/master/changelog.txt").Result;
|
|
client.Dispose();
|
|
}
|
|
catch { return false; }
|
|
return LocalVersion != currentVersion;
|
|
}
|
|
|
|
//Call this to ask the user if they want to update
|
|
public static void Update()
|
|
{
|
|
RawGitHubUrl = $"https://raw.githubusercontent.com/nerdunit/androidsideloader";
|
|
GitHubUrl = $"https://github.com/nerdunit/androidsideloader";
|
|
if (IsUpdateAvailable())
|
|
doUpdate();
|
|
}
|
|
|
|
//If the user wants to update
|
|
private static void doUpdate()
|
|
{
|
|
DialogResult dialogResult = FlexibleMessageBox.Show($"There is a new update you have version {LocalVersion}, do you want to update?\nCHANGELOG\n{changelog}", $"Version {currentVersion} is available", MessageBoxButtons.YesNo);
|
|
if (dialogResult != DialogResult.Yes)
|
|
return;
|
|
|
|
//Download new sideloader with version appended to file name so there is no chance of overwriting the current exe
|
|
try
|
|
{
|
|
var fileClient = new WebClient();
|
|
ServicePointManager.Expect100Continue = true;
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
|
Logger.Log($"Downloading update from {RawGitHubUrl}/releases/download/v{currentVersion}/{AppName}.exe to {AppName} v{currentVersion}.exe");
|
|
fileClient.DownloadFile($"{GitHubUrl}/releases/download/v{currentVersion}/{AppName}.exe", $"{AppName} v{currentVersion}.exe");
|
|
fileClient.Dispose();
|
|
|
|
Logger.Log($"Starting {AppName} v{currentVersion}.exe");
|
|
Process.Start($"{AppName} v{currentVersion}.exe");
|
|
//Delete current version
|
|
AndroidSideloader.Utilities.GeneralUtilities.Melt();
|
|
}
|
|
catch { }
|
|
}
|
|
}
|
|
}
|