Forced healing works!

This commit is contained in:
Timothy Baldridge 2021-12-18 10:38:16 -07:00
parent 87093a1149
commit becabefd8c
2 changed files with 3 additions and 25 deletions

View File

@ -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;
@ -172,28 +172,6 @@ namespace Wabbajack.Lib.Downloaders
return await a.State.FindUpgrade(a, downloadResolver);
}
private static async Task<bool> 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<bool> Download(Archive archive, AbsolutePath destination)
{
try

View File

@ -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}");