From becabefd8c6b6a3fe86ce92322b2399e22953be3 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Sat, 18 Dec 2021 10:38:16 -0700 Subject: [PATCH] Forced healing works! --- .../Downloaders/DownloadDispatcher.cs | 26 ++----------------- Wabbajack.Server/Controllers/AuthoredFiles.cs | 2 +- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs b/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs index a0f38a13..3e986f68 100644 --- a/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs +++ b/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs @@ -123,13 +123,13 @@ namespace Wabbajack.Lib.Downloaders return DownloadResult.Failure; } - if (replacementMeta.Status == ArchiveStatus.Mirrored && await DownloadFromMirror(replacementMeta.PatchedFrom!, destination)) + if (replacementMeta.Status == ArchiveStatus.Mirrored && await Download(replacementMeta.PatchedFrom!, destination)) { await destination.FileHashCachedAsync(); return DownloadResult.Mirror; } - if (replacementMeta.Status != ArchiveStatus.Updated || !(archive.State is IUpgradingState)) + if (replacementMeta.Status != ArchiveStatus.Updated) { Utils.Log($"Download failed for {archive.Name} and no upgrade from this download source is possible"); return DownloadResult.Failure; @@ -171,29 +171,7 @@ namespace Wabbajack.Lib.Downloaders downloadResolver ??= async a => default; return await a.State.FindUpgrade(a, downloadResolver); } - - private static async Task DownloadFromMirror(Archive archive, AbsolutePath destination) - { - try - { - var url = await ClientAPI.GetMirrorUrl(archive.Hash); - if (url == null) return false; - - var newArchive = - new Archive( - new WabbajackCDNDownloader.State(url)) - { - Hash = archive.Hash, Size = archive.Size, Name = archive.Name - }; - return await Download(newArchive, destination); - } - catch (Exception) - { - return false; - } - } - private static async Task Download(Archive archive, AbsolutePath destination) { try diff --git a/Wabbajack.Server/Controllers/AuthoredFiles.cs b/Wabbajack.Server/Controllers/AuthoredFiles.cs index 1daf15a5..eb15cbb6 100644 --- a/Wabbajack.Server/Controllers/AuthoredFiles.cs +++ b/Wabbajack.Server/Controllers/AuthoredFiles.cs @@ -58,7 +58,7 @@ namespace Wabbajack.BuildServer.Controllers if (ms.Length != part.Size) return BadRequest($"Couldn't read enough data for part {part.Size} vs {ms.Length}"); - var hash = ms.xxHash(); + var hash = await ms.xxHashAsync(); if (hash != part.Hash) return BadRequest($"Hashes don't match for index {index}. Sizes ({ms.Length} vs {part.Size}). Hashes ({hash} vs {part.Hash}");