debug packages not downloading properly over http

This commit is contained in:
pizzaboxer 2023-08-31 10:26:05 +01:00
parent 680f6dfda3
commit 63b91efe39
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 23 additions and 6 deletions

View File

@ -1365,9 +1365,11 @@ namespace Bloxstrap
_totalDownloadedBytes += bytesRead; _totalDownloadedBytes += bytesRead;
UpdateProgressBar(); UpdateProgressBar();
} }
if (MD5Hash.FromStream(fileStream) != package.Signature) string hash = MD5Hash.FromStream(fileStream);
throw new Exception("Signature does not match!");
if (hash != package.Signature)
throw new ChecksumFailedException($"Failed to verify download of {packageUrl}\n\nGot signature: {hash}\n\nPackage has been downloaded to {packageLocation}\n\nPlease send the file shown above in a bug report.");
App.Logger.WriteLine(LOG_IDENT, $"Finished downloading! ({totalBytesRead} bytes total)"); App.Logger.WriteLine(LOG_IDENT, $"Finished downloading! ({totalBytesRead} bytes total)");
break; break;
@ -1377,12 +1379,12 @@ namespace Bloxstrap
App.Logger.WriteLine(LOG_IDENT, $"An exception occurred after downloading {totalBytesRead} bytes. ({i}/{maxTries})"); App.Logger.WriteLine(LOG_IDENT, $"An exception occurred after downloading {totalBytesRead} bytes. ({i}/{maxTries})");
App.Logger.WriteException(LOG_IDENT, ex); App.Logger.WriteException(LOG_IDENT, ex);
if (i >= maxTries || ex.GetType() == typeof(ChecksumFailedException))
throw;
if (File.Exists(packageLocation)) if (File.Exists(packageLocation))
File.Delete(packageLocation); File.Delete(packageLocation);
if (i >= maxTries)
throw;
_totalDownloadedBytes -= totalBytesRead; _totalDownloadedBytes -= totalBytesRead;
UpdateProgressBar(); UpdateProgressBar();

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bloxstrap.Exceptions
{
internal class ChecksumFailedException : Exception
{
public ChecksumFailedException(string message) : base(message)
{
}
}
}