2021-09-27 12:42:46 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Wabbajack.DTOs;
|
|
|
|
using Wabbajack.DTOs.DownloadStates;
|
|
|
|
using Wabbajack.DTOs.Validation;
|
|
|
|
using Wabbajack.Hashing.xxHash64;
|
|
|
|
using Wabbajack.Paths;
|
|
|
|
using Wabbajack.RateLimiter;
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.Downloaders.Interfaces;
|
|
|
|
|
|
|
|
public abstract class ADownloader<T> : IDownloader<T>
|
|
|
|
where T : IDownloadState
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
public abstract Task<Hash> Download(Archive archive, T state, AbsolutePath destination,
|
|
|
|
IJob job, CancellationToken token);
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public bool CanDownload(Archive a)
|
|
|
|
{
|
|
|
|
return a.State is T;
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public Task<Hash> Download(Archive archive, AbsolutePath destination, IJob job, CancellationToken token)
|
|
|
|
{
|
|
|
|
return Download(archive, (T) archive.State, destination, job, token);
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public Task<bool> Verify(Archive archive, IJob job, CancellationToken token)
|
|
|
|
{
|
|
|
|
return Verify(archive, (T) archive.State, job, token);
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public abstract Task<bool> Prepare();
|
|
|
|
public abstract bool IsAllowed(ServerAllowList allowList, IDownloadState state);
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public IEnumerable<string> MetaIni(Archive a)
|
|
|
|
{
|
|
|
|
return MetaIni(a, (T) a.State);
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public abstract IDownloadState? Resolve(IReadOnlyDictionary<string, string> iniData);
|
|
|
|
public abstract Priority Priority { get; }
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public abstract Task<bool> Verify(Archive archive, T archiveState, IJob job, CancellationToken token);
|
|
|
|
public abstract IEnumerable<string> MetaIni(Archive a, T state);
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|