Several small tweaks for auto healing

This commit is contained in:
Timothy Baldridge 2020-05-30 15:05:26 -06:00
parent 06a20fc095
commit 0933e15c9e
5 changed files with 20 additions and 8 deletions

View File

@ -26,5 +26,16 @@ namespace Wabbajack.Common.Test
Assert.True(Utils.TryGetHashCache(testFile, out var fileHash));
Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), fileHash);
}
[Fact]
public void TestHashHex()
{
var hash = Hash.FromULong((ulong)Utils.NextRandom(0, int.MaxValue));
Assert.Equal(hash, Hash.FromHex(hash.ToHex()));
hash = Hash.FromLong(4085310893299329733);
Assert.Equal(hash, Hash.FromHex(hash.ToHex()));
}
}
}

View File

@ -66,10 +66,7 @@ namespace Wabbajack.Common
return BitConverter.ToInt64(BitConverter.GetBytes(a._code));
}
public string ToHex()
{
return BitConverter.GetBytes(_code).ToHex();
}
public string ToBase64()
{
@ -97,6 +94,10 @@ namespace Wabbajack.Common
{
return new Hash(BitConverter.ToUInt64(xxHashAsHex.FromHex()));
}
public string ToHex()
{
return BitConverter.GetBytes(_code).ToHex();
}
public byte[] ToArray()
{

View File

@ -118,7 +118,7 @@ namespace Wabbajack.Lib.Downloaders
}
Utils.Log($"Looking for patch for {archive.Name}");
Utils.Log($"Looking for patch for {archive.Name} ({(long)archive.Hash} {archive.Hash.ToHex()} -> {(long)result.Archive!.Hash} {result.Archive!.Hash.ToHex()})");
var patchResult = await ClientAPI.GetModUpgrade(archive, result.Archive!);
Utils.Log($"Downloading patch for {archive.Name}");

View File

@ -131,14 +131,14 @@ namespace Wabbajack.Server.DataLayer
"SELECT SrcId, DestId, PatchSize, Finished, IsFailed, FailMessage FROM dbo.Patches WHERE SrcId = @SrcId", new {SrcId = sourceDownload});
List<Patch> results = new List<Patch>();
foreach (var (srcId, destId, patchSize, finished, isFinished, failMessage) in patches)
foreach (var (srcId, destId, patchSize, finished, isFailed, failMessage) in patches)
{
results.Add( new Patch {
Src = await GetArchiveDownload(srcId),
Dest = await GetArchiveDownload(destId),
PatchSize = patchSize,
Finished = finished,
IsFailed = isFinished,
IsFailed = isFailed,
FailMessage = failMessage
});
}

View File

@ -158,7 +158,7 @@ namespace Wabbajack.Server.Services
return (archive, ArchiveStatus.Updating);
if (patch.IsFailed == true)
continue;
return (archive, ArchiveStatus.InValid);
var (_, status) = await ValidateArchive(data, patch.Dest.Archive);
if (status == ArchiveStatus.Valid)