Merge branch 'main' into port-app

This commit is contained in:
Timothy Baldridge 2022-01-04 20:27:39 -07:00 committed by GitHub
commit 5ebb06b6d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View File

@ -16,6 +16,7 @@ using Wabbajack.Compiler.PatchCache;
using Wabbajack.Downloaders;
using Wabbajack.Downloaders.Interfaces;
using Wabbajack.DTOs;
using Wabbajack.DTOs.Configs;
using Wabbajack.DTOs.DownloadStates;
using Wabbajack.DTOs.GitHub;
using Wabbajack.DTOs.JsonConverters;
@ -99,9 +100,12 @@ public class ValidateLists : IVerb
var patchFiles = await _wjClient.GetAllPatches(token);
_logger.LogInformation("Found {Count} patches", patchFiles.Length);
var forcedRemovals = (await _wjClient.GetForcedRemovals(token)).ToLookup(f => f.Hash);
_logger.LogInformation("Found {Count} forced removals", forcedRemovals.Count);
var validationCache = new LazyCache<string, Archive, (ArchiveStatus Status, Archive archive)>
(x => x.State.PrimaryKeyString + x.Hash,
archive => DownloadAndValidate(archive, token));
archive => DownloadAndValidate(archive, forcedRemovals, token));
var stopWatch = Stopwatch.StartNew();
var listData = await lists.SelectAsync(async l => await _gitHubClient.GetData(l))
@ -375,8 +379,12 @@ public class ValidateLists : IVerb
}
}
private async Task<(ArchiveStatus, Archive)> DownloadAndValidate(Archive archive, CancellationToken token)
private async Task<(ArchiveStatus, Archive)> DownloadAndValidate(Archive archive,
ILookup<Hash, ForcedRemoval> forcedRemovals, CancellationToken token)
{
if (forcedRemovals.Contains(archive.Hash))
return (ArchiveStatus.InValid, archive);
switch (archive.State)
{
case GameFileSource:

View File

@ -0,0 +1,10 @@
using Wabbajack.Hashing.xxHash64;
namespace Wabbajack.DTOs.Configs;
public class ForcedRemoval
{
public string Name { get; set; }
public string Reason { get; set; }
public Hash Hash { get; set; }
}

View File

@ -12,6 +12,7 @@ using Microsoft.Extensions.Logging;
using Wabbajack.Common;
using Wabbajack.DTOs;
using Wabbajack.DTOs.CDN;
using Wabbajack.DTOs.Configs;
using Wabbajack.DTOs.JsonConverters;
using Wabbajack.DTOs.Logins;
using Wabbajack.DTOs.ModListValidation;
@ -330,8 +331,13 @@ public class Client
throw new HttpException(result);
}
public (IObservable<(Percent PercentDone, string Message)> Progress, Task<Uri> Task) UploadAuthorFile(AbsolutePath pickerTargetPath)
{
throw new NotImplementedException();
}
public async Task<ForcedRemoval[]> GetForcedRemovals(CancellationToken token)
{
return (await _client.GetFromJsonAsync<ForcedRemoval[]>("https://raw.githubusercontent.com/wabbajack-tools/mod-lists/master/configs/forced_removal.json", _dtos.Options, token))!;
}
}