mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Delete old mirrored files
This commit is contained in:
parent
a3e545281e
commit
77bd85bb47
@ -227,6 +227,13 @@ public class ValidateLists : IVerb
|
||||
}
|
||||
|
||||
await ExportReports(reports, validatedLists, token);
|
||||
|
||||
|
||||
var usedMirroredFiles = validatedLists.SelectMany(a => a.Archives)
|
||||
.Where(m => m.Status == ArchiveStatus.Mirrored)
|
||||
.Select(m => m.Original.Hash)
|
||||
.ToHashSet();
|
||||
await DeleteOldMirrors(mirroredFiles, usedMirroredFiles);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -356,6 +363,16 @@ public class ValidateLists : IVerb
|
||||
await using var upgradedMetasFile = reports.Combine("upgraded.json")
|
||||
.Open(FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
await _dtos.Serialize(upgradedMetas, upgradedMetasFile, true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async Task DeleteOldMirrors(IEnumerable<Hash> mirroredFiles, IReadOnlySet<Hash> usedMirroredFiles)
|
||||
{
|
||||
foreach (var file in mirroredFiles.Where(file => !usedMirroredFiles.Contains(file)))
|
||||
{
|
||||
await _wjClient.DeleteMirror(file);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<(ArchiveStatus, Archive)> DownloadAndValidate(Archive archive, CancellationToken token)
|
||||
|
@ -320,4 +320,13 @@ public class Client
|
||||
{
|
||||
return (await _client.GetFromJsonAsync<ValidatedArchive[]>("https://raw.githubusercontent.com/wabbajack-tools/mod-lists/master/configs/forced_healing.json", _dtos.Options, token))!;
|
||||
}
|
||||
|
||||
public async Task DeleteMirror(Hash hash)
|
||||
{
|
||||
_logger.LogInformation("Deleting mirror of {Hash}", hash);
|
||||
var msg = await MakeMessage(HttpMethod.Delete, new Uri($"{_configuration.BuildServerUrl}mirrored_files/{hash.ToHex()}"));
|
||||
var result = await _client.SendAsync(msg);
|
||||
if (!result.IsSuccessStatusCode)
|
||||
throw new HttpException(result);
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ public class WabbajackApiTokenProvider : ITokenProvider<WabbajackApiState>
|
||||
return new WabbajackApiState
|
||||
{
|
||||
MetricsKey = wjToken,
|
||||
AuthorKey = AuthorKeyPath.FileExists() ? await AuthorKeyPath.ReadAllTextAsync() : null
|
||||
AuthorKey = AuthorKeyPath.FileExists() ? (await AuthorKeyPath.ReadAllTextAsync()).Trim() : null
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user