Show Download progress on updates (needs to be tested)

This commit is contained in:
CreepyCrafter24 2019-10-20 18:31:32 +02:00
parent df04a2002f
commit c000acf098
3 changed files with 15 additions and 13 deletions

View File

@ -1,5 +1,6 @@
More Icons for Apps
More apps: Laptop Sim (when done)
Use local info when building GUI (Except name/description)
Decent updater
Save Images on disk to allow offline usage
Decent updater and Installer (Do not open CMD)
Save Images on disk to allow offline usage
Test Updates

View File

@ -36,11 +36,12 @@ namespace UpTool2
Directory.CreateDirectory(app);
if (new DownloadDialog(appI.file, app + @"\package.zip").ShowDialog() != DialogResult.OK)
throw new Exception("Download failed");
SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider();
string pkghash = BitConverter.ToString(sha256.ComputeHash(File.ReadAllBytes(app + @"\package.zip"))).Replace("-", string.Empty).ToUpper();
if (pkghash != appI.hash.ToUpper())
throw new Exception("The hash is not equal to the one stored in the repo:\r\nPackage: " + pkghash + "\r\nOnline: " + appI.hash.ToUpper());
sha256.Dispose();
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
{
string pkghash = BitConverter.ToString(sha256.ComputeHash(File.ReadAllBytes(app + @"\package.zip"))).Replace("-", string.Empty).ToUpper();
if (pkghash != appI.hash.ToUpper())
throw new Exception("The hash is not equal to the one stored in the repo:\r\nPackage: " + pkghash + "\r\nOnline: " + appI.hash.ToUpper());
}
completeInstall(app, appI);
#if !DEBUG
}

View File

@ -85,14 +85,14 @@ namespace UpTool2
int version = int.Parse(meta.Element("Version").Value);
if (int.Parse(XDocument.Load(xml).Element("meta").Element("Version").Value) < version)
{
using (var client = new WebClient())
if (new DownloadDialog(meta.Element("File").Value, dir + @"\update.exe").ShowDialog() != DialogResult.OK)
throw new Exception("Failed to update");
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
{
client.DownloadFile(meta.Element("File").Value, dir + @"\update.exe");
string pkghash = BitConverter.ToString(sha256.ComputeHash(File.ReadAllBytes(dir + @"\update.exe"))).Replace("-", string.Empty).ToUpper();
if (pkghash != meta.Element("Hash").Value.ToUpper())
throw new Exception("The hash is not equal to the one stored in the repo:\r\nPackage: " + pkghash + "\r\nOnline: " + meta.Element("Hash").Value.ToUpper());
}
SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider();
if (BitConverter.ToString(sha256.ComputeHash(File.ReadAllBytes(dir + @"\update.exe"))).Replace("-", string.Empty).ToUpper() != meta.Element("Hash").Value)
throw new Exception("The hash is not equal to the one stored in the repo");
sha256.Dispose();
new XElement("meta", new XElement("Version", version)).Save(xml);
splash.Hide();
Process.Start(new ProcessStartInfo { FileName = "cmd.exe", Arguments = "/C echo Running Update & timeout /t 4 & copy /b/v/y \"" + dir + @"\update.exe" + "\" \"" + Application.ExecutablePath + "\" & echo Done Updating, please restart & pause" });