mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Implement forced removals
This commit is contained in:
parent
adba503183
commit
e7b5763906
@ -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:
|
||||
|
10
Wabbajack.DTOs/Configs/ForcedRemoval.cs
Normal file
10
Wabbajack.DTOs/Configs/ForcedRemoval.cs
Normal 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; }
|
||||
}
|
@ -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;
|
||||
@ -329,4 +330,10 @@ public class Client
|
||||
if (!result.IsSuccessStatusCode)
|
||||
throw new HttpException(result);
|
||||
}
|
||||
|
||||
public async Task<ForcedRemoval[]> GetForcedRemovals(CancellationToken token)
|
||||
{
|
||||
return (await _client.GetFromJsonAsync<ForcedRemoval[]>("https://raw.githubusercontent.com/wabbajack-tools/mod-lists/master/configs/forced_remova..json", _dtos.Options, token))!;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user