Add VectorPlexus and LoversLab stubs for old download formats

This commit is contained in:
Timothy Baldridge 2021-06-19 10:16:22 -06:00
parent fa50b4cf4b
commit 2b1e0f73cf
10 changed files with 122 additions and 5 deletions

View File

@ -0,0 +1,61 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Wabbajack.Common;
using Wabbajack.Common.Serialization.Json;
using Wabbajack.Lib.Validation;
namespace Wabbajack.Lib.Downloaders
{
public class ADeprecatedDownloader<TDownloader, TState> : IDownloader
where TDownloader: ADeprecatedDownloader<TDownloader, TState>
where TState: ADeprecatedDownloader<TDownloader, TState>.State
{
public async Task<AbstractDownloadState?> GetDownloaderState(dynamic archiveINI, bool quickMode = false)
{
return null;
}
public async Task Prepare()
{
return;
}
public class State : AbstractDownloadState
{
[JsonName("PrimaryKeyString")] private string _primaryKeyString { get; set; } = "";
public override object[] PrimaryKey => _primaryKeyString.Split("|").Cast<object>().ToArray();
public override bool IsWhitelisted(ServerWhitelist whitelist)
{
return true;
}
public override Task<bool> Download(Archive a, AbsolutePath destination)
{
throw new Exception($"Downloader {this.GetType().FullName} is deprecated");
}
public override async Task<bool> Verify(Archive archive, CancellationToken? token = null)
{
return false;
}
public override IDownloader GetDownloader()
{
return DownloadDispatcher.GetInstance<TDownloader>();
}
public override string? GetManifestURL(Archive a)
{
return null;
}
public override string[] GetMetaIni()
{
return new[] {"[General]", "downloaderIsDeprecated=True"};
}
}
}
}

View File

@ -26,6 +26,7 @@ namespace Wabbajack.Lib.Downloaders
{
public static List<Type> KnownSubTypes = new List<Type>
{
typeof(DeprecatedLoversLabDownloader.State),
typeof(HTTPDownloader.State),
typeof(GameFileSourceDownloader.State),
typeof(GoogleDriveDownloader.State),

View File

@ -0,0 +1,12 @@
using Wabbajack.Common.Serialization.Json;
namespace Wabbajack.Lib.Downloaders
{
public class DeprecatedLoversLabDownloader : ADeprecatedDownloader<DeprecatedLoversLabDownloader, DeprecatedLoversLabDownloader.State>
{
[JsonName("LoversLabDownloader")]
public class State : ADeprecatedDownloader<DeprecatedLoversLabDownloader, DeprecatedLoversLabDownloader.State>.State
{
}
}
}

View File

@ -0,0 +1,12 @@
using Wabbajack.Common.Serialization.Json;
namespace Wabbajack.Lib.Downloaders
{
public class DeprecatedVectorPlexusDownloader : ADeprecatedDownloader<DeprecatedVectorPlexusDownloader, DeprecatedVectorPlexusDownloader.State>
{
[JsonName("VectorPlexusDownloader")]
public class State : ADeprecatedDownloader<DeprecatedVectorPlexusDownloader, DeprecatedVectorPlexusDownloader.State>.State
{
}
}
}

View File

@ -30,6 +30,8 @@ namespace Wabbajack.Lib.Downloaders
new YandexDownloader(),
new HTTPDownloader(),
new ManualDownloader(),
new DeprecatedVectorPlexusDownloader(),
new DeprecatedLoversLabDownloader(),
};
public static readonly List<IUrlInferencer> Inferencers = new List<IUrlInferencer>()

View File

@ -27,7 +27,7 @@ namespace Wabbajack.Lib.Downloaders
}
[JsonName("LoversLabOAuthDownloader+State")]
[JsonName("LoversLabOAuthDownloader")]
public class State : AbstractIPS4OAuthDownloader<LoversLabOAuthDownloader, LoversLabOAuthDownloader.State>.State
{
public override IDownloader GetDownloader()

View File

@ -24,9 +24,9 @@ namespace Wabbajack
/// <param name="This">Object to watch</param>
/// <param name="property1">Expression path to the property to subscribe to</param>
/// <returns></returns>
public static IObservable<TRet> WhenAny<TSender, TRet>(
public static IObservable<TRet?> WhenAny<TSender, TRet>(
this TSender This,
Expression<Func<TSender, TRet>> property1)
Expression<Func<TSender, TRet?>> property1)
where TSender : class
{
return This.WhenAny(property1, selector: x => x.GetValue());

View File

@ -347,8 +347,13 @@ namespace Wabbajack.Test
Assert.Equal("Cheese for Everyone!", await filename.Path.ReadAllTextAsync());
}
[Fact]
public async Task CanLoadOldLLMeta()
{
var state = (DeprecatedLoversLabDownloader.State)(AbsolutePath.EntryPoint.Combine(@"Resources\LoversLabState.json").FromJson<Archive>().State);
Assert.Equal("", state.PrimaryKeyString);
}
[Fact]
public async Task VectorPlexusDownload()

View File

@ -0,0 +1,21 @@
{
"$type": "Archive, Wabbajack.Lib",
"Hash": "WLBnqZUBA/8=",
"Meta": "[General]\ndirectURL=http://www.loverslab.com/files/file/5815-uslep-unpatch/?do=download&r=665125&confirm=1&t=1",
"Name": "USLEP_UnPatch_V104.7z",
"Size": 11962608,
"State": {
"$type": "LoversLabDownloader, Wabbajack.Lib",
"FullURL": "/files/file/5815-uslep-unpatch/",
"IsAttachment": false,
"FileID": "665125",
"FileName": "5815-uslep-unpatch",
"URL": "http://www.loverslab.com/files/file/5815-uslep-unpatch",
"Name": "USLEP UnPatch V1.04",
"Author": "MadMansGun",
"Version": "V1.04",
"ImageURL": null,
"Description": null,
"PrimaryKeyString": "LoversLabDownloader+State|https://www.loverslab.com/|5815-uslep-unpatch|665125"
}
}

View File

@ -25,6 +25,9 @@
<None Update="Resources\test_ini01.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Resources\LoversLabState.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>