Extractor fixes for broken Lucian introspection

This commit is contained in:
Timothy Baldridge 2020-11-01 21:06:18 -07:00
parent f80ae8b142
commit 0c5913c70a
4 changed files with 29 additions and 4 deletions

View File

@ -40,6 +40,12 @@ namespace Wabbajack.Common
}
this.DeleteAfter = deleteAfter;
}
public TempFile(Extension ext)
:this(new FileInfo((string)GetTempFilePath().WithExtension(ext)))
{
}
public async ValueTask DisposeAsync()
{
if (DeleteAfter && Path.Exists)

View File

@ -224,7 +224,7 @@ namespace Wabbajack.VirtualFileSystem.Test
}
private static AbsolutePath _stagingFolder = ((RelativePath)"NexusDownloads").RelativeToEntryPoint();
public static AbsolutePath StagingFolder = ((RelativePath)"NexusDownloads").RelativeToEntryPoint();
private static async Task<AbsolutePath> DownloadMod(Game game, int mod)
{
@ -235,9 +235,9 @@ namespace Wabbajack.VirtualFileSystem.Test
return await DownloadNexusFile(game, mod, file);
}
private static async Task<AbsolutePath> DownloadNexusFile(Game game, int mod, NexusFileInfo file)
public static async Task<AbsolutePath> DownloadNexusFile(Game game, int mod, NexusFileInfo file)
{
var src = _stagingFolder.Combine(file.file_name);
var src = StagingFolder.Combine(file.file_name);
if (src.Exists) return src;
@ -251,7 +251,7 @@ namespace Wabbajack.VirtualFileSystem.Test
return src;
}
private async Task<AbsolutePath> DownloadMod(Game game, int mod, int fileId)
public static async Task<AbsolutePath> DownloadMod(Game game, int mod, int fileId)
{
using var client = await NexusApiClient.Get();
var results = await client.GetModFiles(game, mod);

View File

@ -5,6 +5,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wabbajack.Common;
using Wabbajack.Lib;
using Wabbajack.Lib.Downloaders;
using Xunit;
using Xunit.Abstractions;
@ -186,6 +188,22 @@ namespace Wabbajack.VirtualFileSystem.Test
}
[Theory]
[InlineData(Game.SkyrimSpecialEdition, 20035, 130759)] // Lucian
public async Task CanAnalyzeMods(Game game, int modid, int fileId)
{
await using var tmpFolder = await TempFolder.Create();
var path = await FileExtractorTests.DownloadMod(game, modid, fileId);
await path.CopyToAsync(path.FileName.RelativeTo(tmpFolder.Dir));
var context = new Context(Queue);
await context.AddRoot(tmpFolder.Dir);
Assert.True(context.Index.ByFullPath.Count >= 3);
}
private static async Task AddFile(AbsolutePath filename, string text)
{
filename.Parent.CreateDirectory();

View File

@ -199,6 +199,7 @@ namespace Wabbajack.VirtualFileSystem
.WithExtension(source.Extension));
await using var s = await sf.GetStream();
await spoolFile.Path.WriteAllAsync(s);
source = spoolFile.Path;
}
Utils.Log(new GenericInfo($"Extracting {(string)source.FileName}",