mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
WIP bugfixes
This commit is contained in:
parent
f99f4a7538
commit
3d61847b0b
@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using Wabbajack.Paths;
|
||||
|
||||
namespace Wabbajack.Compiler;
|
||||
|
||||
public class MO2CompilerSettings : CompilerSettings
|
||||
{
|
||||
public string Profile { get; set; }
|
||||
public RelativePath[] AlwaysEnabled { get; set; }
|
||||
public string Profile { get; set; } = "";
|
||||
public RelativePath[] AlwaysEnabled { get; set; } = Array.Empty<RelativePath>();
|
||||
}
|
@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Wabbajack.DTOs.JsonConverters;
|
||||
using Wabbajack.Networking.WabbajackClientApi;
|
||||
using Wabbajack.Services.OSIntegrated;
|
||||
|
||||
namespace Wabbajack.DTOs.Test;
|
||||
|
||||
@ -10,10 +11,6 @@ public class Startup
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddDTOConverters();
|
||||
services.AddDTOSerializer();
|
||||
services.AddWabbajackClient();
|
||||
services.AddSingleton(new ParallelOptions {MaxDegreeOfParallelism = 2});
|
||||
services.AddSingleton<HttpClient>();
|
||||
services.AddOSIntegrated();
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
<ProjectReference Include="..\Wabbajack.DTOs\Wabbajack.DTOs.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Networking.WabbajackClientApi\Wabbajack.Networking.WabbajackClientApi.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Paths.IO\Wabbajack.Paths.IO.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Services.OSIntegrated\Wabbajack.Services.OSIntegrated.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -76,7 +76,6 @@ public class FileExtractor
|
||||
|
||||
|
||||
IDictionary<RelativePath, T> results;
|
||||
using var job = await _limiter.Begin($"Extracting {sFn.Name}", 0, token);
|
||||
|
||||
switch (sig)
|
||||
{
|
||||
@ -93,7 +92,7 @@ public class FileExtractor
|
||||
{
|
||||
await using var tempFolder = _manager.CreateFolder();
|
||||
results = await GatheringExtractWith7Zip(sFn, shouldExtract,
|
||||
mapfn, onlyFiles, job, token);
|
||||
mapfn, onlyFiles, token);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -153,7 +152,7 @@ public class FileExtractor
|
||||
return results;
|
||||
}
|
||||
|
||||
public static async Task<Dictionary<RelativePath, T>> GatheringExtractWithBSA<T>(IStreamFactory sFn,
|
||||
public async Task<Dictionary<RelativePath, T>> GatheringExtractWithBSA<T>(IStreamFactory sFn,
|
||||
FileType sig,
|
||||
Predicate<RelativePath> shouldExtract,
|
||||
Func<RelativePath, IExtractedFile, ValueTask<T>> mapFn,
|
||||
@ -172,6 +171,7 @@ public class FileExtractor
|
||||
results.Add(entry.Path, result);
|
||||
}
|
||||
|
||||
_logger.LogInformation("Finished extracting {Name}", sFn.Name);
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -179,7 +179,6 @@ public class FileExtractor
|
||||
Predicate<RelativePath> shouldExtract,
|
||||
Func<RelativePath, IExtractedFile, ValueTask<T>> mapfn,
|
||||
IReadOnlyCollection<RelativePath>? onlyFiles,
|
||||
Job<FileExtractor> job,
|
||||
CancellationToken token)
|
||||
{
|
||||
TemporaryPath? tmpFile = null;
|
||||
@ -188,6 +187,7 @@ public class FileExtractor
|
||||
TemporaryPath? spoolFile = null;
|
||||
AbsolutePath source;
|
||||
|
||||
var job = await _limiter.Begin($"Extracting {sf.Name}", 0, token);
|
||||
try
|
||||
{
|
||||
if (sf.Name is AbsolutePath abs)
|
||||
@ -202,7 +202,7 @@ public class FileExtractor
|
||||
source = spoolFile.Value.Path;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Extracting {source}", source.FileName);
|
||||
_logger.LogInformation("Extracting {Source}", source.FileName);
|
||||
|
||||
|
||||
var initialPath = "";
|
||||
@ -278,6 +278,8 @@ public class FileExtractor
|
||||
Utils.Status($"Extracting {source.FileName} - done", Percent.One, alsoLog: true);
|
||||
}*/
|
||||
|
||||
|
||||
job.Dispose();
|
||||
var results = await dest.Path.EnumerateFiles()
|
||||
.PMapAll(async f =>
|
||||
{
|
||||
@ -295,6 +297,8 @@ public class FileExtractor
|
||||
}
|
||||
finally
|
||||
{
|
||||
job.Dispose();
|
||||
|
||||
if (tmpFile != null) await tmpFile.Value.DisposeAsync();
|
||||
|
||||
if (spoolFile != null) await spoolFile.Value.DisposeAsync();
|
||||
|
@ -11,8 +11,12 @@ public class Job<T> : IJob, IDisposable
|
||||
public bool Started { get; internal set; }
|
||||
public IResource<T> Resource { get; init; }
|
||||
|
||||
private bool _isFinished = false;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!_isFinished) return;
|
||||
_isFinished = true;
|
||||
Resource.Finish(this);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class Resource<T> : IResource<T>
|
||||
private long _totalUsed;
|
||||
|
||||
|
||||
public Resource(string? humanName = null, int? maxTasks = 0, long maxThroughput = long.MaxValue)
|
||||
public Resource(string? humanName = null, int? maxTasks = null, long maxThroughput = long.MaxValue)
|
||||
{
|
||||
Name = humanName ?? "<unknown>";
|
||||
MaxTasks = maxTasks ?? Environment.ProcessorCount;
|
||||
|
@ -63,6 +63,9 @@ public static class ServiceExtensions
|
||||
service.AddAllSingleton<IResource, IResource<FileExtractor.FileExtractor>>(s =>
|
||||
new Resource<FileExtractor.FileExtractor>("File Extractor", 12));
|
||||
|
||||
service.AddAllSingleton<IResource, IResource<ACompiler>>(s =>
|
||||
new Resource<ACompiler>("Compiler", 12));
|
||||
|
||||
service.AddSingleton<LoggingRateLimiterReporter>();
|
||||
|
||||
service.AddScoped<Context>();
|
||||
|
@ -18,6 +18,10 @@ public class Startup
|
||||
.AddAllSingleton<IResource, IResource<FileExtractor.FileExtractor>, Resource<FileExtractor.FileExtractor>>(
|
||||
s =>
|
||||
new Resource<FileExtractor.FileExtractor>("File Extractor", 2));
|
||||
service
|
||||
.AddAllSingleton<IResource, IResource<Context>, Resource<Context>>(
|
||||
s =>
|
||||
new ("VFS Context", 2));
|
||||
|
||||
// Keep this fixed at 2 so that we can detect deadlocks in the VFS parallelOptions
|
||||
service.AddSingleton(new ParallelOptions {MaxDegreeOfParallelism = 2});
|
||||
|
@ -156,11 +156,6 @@ public class Context
|
||||
async file => await HandleFile(file, new ExtractedNativeFile(file.AbsoluteName) {CanMove = false}));
|
||||
}
|
||||
|
||||
private class Box<T>
|
||||
{
|
||||
public T Value { get; set; }
|
||||
}
|
||||
|
||||
#region KnownFiles
|
||||
|
||||
private List<HashRelativePath> _knownFiles = new();
|
||||
|
Loading…
Reference in New Issue
Block a user