From 09db4744e2788287e9750791e70535962fae356f Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Mon, 16 May 2022 17:18:10 -0600 Subject: [PATCH] Delete bad downloads --- Wabbajack.Installer/AInstaller.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Wabbajack.Installer/AInstaller.cs b/Wabbajack.Installer/AInstaller.cs index 02e38ab1..9340388a 100644 --- a/Wabbajack.Installer/AInstaller.cs +++ b/Wabbajack.Installer/AInstaller.cs @@ -298,7 +298,7 @@ public abstract class AInstaller foreach (var a in missing.Where(a => a.State is Manual)) { var outputPath = _configuration.Downloads.Combine(a.Name); - await _downloadDispatcher.Download(a, outputPath, token); + await DownloadArchive(a, true, token, outputPath); } } @@ -323,7 +323,7 @@ public abstract class AInstaller outputPath.Delete(); } - await DownloadArchive(archive, download, token, outputPath); + var hash = await DownloadArchive(archive, download, token, outputPath); UpdateProgress(1); }); } @@ -346,6 +346,17 @@ public abstract class AInstaller var (result, hash) = await _downloadDispatcher.DownloadWithPossibleUpgrade(archive, destination.Value, token); + if (hash != archive.Hash) + { + _logger.LogError("Downloaded hash {Downloaded} does not match expected hash: {Expected}", hash, archive.Hash); + if (destination!.Value.FileExists()) + { + destination!.Value.Delete(); + } + + return false; + } + if (hash != default) _fileHashCache.FileHashWriteCache(destination.Value, hash);