mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #2083 from wabbajack-tools/compiler-performance-fixes
Compiler performance fixes
This commit is contained in:
commit
1941e8161d
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,7 +1,15 @@
|
||||
### Changelog
|
||||
|
||||
#### Version - 3.0.1.5 - 9/??/2022
|
||||
#### Version - 3.0.1.5 - 9/26/2022
|
||||
* Fix MO2ArchiveName resolution
|
||||
* Improve performance of the compiler stack
|
||||
* Save the location of the browser window and open the next window in the same location
|
||||
* Fix a leak of msedgwebview2.exe instances when doing manual downloads
|
||||
* Massively improve patch load times
|
||||
* Massively improve patch build times
|
||||
* Reduce situations where the UI appears to be hung due the above two issues
|
||||
* Fix file extraction progress bars not displaying properly (and going away)
|
||||
* Update status bars to be a bit more accurate
|
||||
|
||||
#### Version - 3.0.1.4 - 9/21/2022
|
||||
* Fix several of case sensitive path comparisons, that could result in deleting downloads
|
||||
|
@ -307,7 +307,7 @@ namespace Wabbajack
|
||||
.Subscribe(update =>
|
||||
{
|
||||
var s = update.EventArgs;
|
||||
StatusText = $"[{s.StepsProgress}] {s.StatusText}";
|
||||
StatusText = $"[Step {s.CurrentStep}] {s.StatusText}";
|
||||
StatusProgress = s.StepProgress;
|
||||
});
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
Style="{StaticResource {x:Type Window}}"
|
||||
TitleBarHeight="25"
|
||||
UseLayoutRounding="True"
|
||||
SaveWindowPosition="True"
|
||||
WindowTitleBrush="{StaticResource MahApps.Brushes.Accent}"
|
||||
ContentRendered="BrowserWindow_OnActivated"
|
||||
mc:Ignorable="d">
|
||||
|
@ -54,6 +54,11 @@ public partial class BrowserWindow : MetroWindow
|
||||
});
|
||||
|
||||
vm.RunWrapper(CancellationToken.None)
|
||||
.ContinueWith(_ => Dispatcher.Invoke(Close));
|
||||
.ContinueWith(_ => Dispatcher.Invoke(() =>
|
||||
{
|
||||
Close();
|
||||
Browser.Dispose();
|
||||
Browser = null;
|
||||
}));
|
||||
}
|
||||
}
|
@ -62,6 +62,47 @@ public static class AsyncParallelExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Faster version of PMapAll for when the function invocation will take a very small amount of time
|
||||
/// batches all the inputs into N groups and executes them all on one task, where N is the number of
|
||||
/// threads supported by the limiter
|
||||
/// </summary>
|
||||
/// <param name="coll"></param>
|
||||
/// <param name="limiter"></param>
|
||||
/// <param name="mapFn"></param>
|
||||
/// <typeparam name="TIn"></typeparam>
|
||||
/// <typeparam name="TJob"></typeparam>
|
||||
/// <typeparam name="TOut"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static async IAsyncEnumerable<TOut> PMapAllBatched<TIn, TJob, TOut>(this IEnumerable<TIn> coll,
|
||||
IResource<TJob> limiter, Func<TIn, Task<TOut>> mapFn)
|
||||
{
|
||||
var asList = coll.ToList();
|
||||
|
||||
var tasks = new List<Task<List<TOut>>>();
|
||||
|
||||
tasks.AddRange(Enumerable.Range(0, limiter.MaxTasks).Select(i => Task.Run(async () =>
|
||||
{
|
||||
using var job = await limiter.Begin(limiter.Name, asList.Count / limiter.MaxTasks, CancellationToken.None);
|
||||
var list = new List<TOut>();
|
||||
for (var idx = i; idx < asList.Count; idx += limiter.MaxTasks)
|
||||
{
|
||||
job.ReportNoWait(1);
|
||||
list.Add(await mapFn(asList[idx]));
|
||||
}
|
||||
|
||||
return list;
|
||||
})));
|
||||
|
||||
foreach (var result in tasks)
|
||||
{
|
||||
foreach (var itm in (await result))
|
||||
{
|
||||
yield return itm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async IAsyncEnumerable<TOut> PKeepAll<TIn, TJob, TOut>(this IEnumerable<TIn> coll,
|
||||
IResource<TJob> limiter, Func<TIn, Task<TOut>> mapFn)
|
||||
where TOut : class
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Wabbajack.Common;
|
||||
@ -13,6 +14,7 @@ public static class IEnumerableExtensions
|
||||
}
|
||||
|
||||
#region Shuffle
|
||||
|
||||
/// https://stackoverflow.com/questions/5807128/an-extension-method-on-ienumerable-needed-for-shuffling
|
||||
|
||||
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source, Random rng)
|
||||
@ -32,6 +34,7 @@ public static class IEnumerableExtensions
|
||||
buffer[j] = buffer[i];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -55,6 +58,22 @@ public static class IEnumerableExtensions
|
||||
return data;
|
||||
}
|
||||
|
||||
public static IEnumerable<IEnumerable<T>> Partition<T>(this IEnumerable<T> coll, int size)
|
||||
{
|
||||
var asList = coll.ToList();
|
||||
|
||||
IEnumerable<T> SkipEnumerable(IList<T> list, int offset, int size)
|
||||
{
|
||||
for (var i = offset; i < list.Count; i += size)
|
||||
{
|
||||
yield return list[i];
|
||||
}
|
||||
}
|
||||
|
||||
return Enumerable.Range(0, size).Select(offset => SkipEnumerable(asList, offset, size));
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<T> OnEach<T>(this IEnumerable<T> coll, Action<T> fn)
|
||||
{
|
||||
foreach (var itm in coll)
|
||||
|
@ -87,6 +87,7 @@ public class ModListHarness
|
||||
settings.ModListName = _profileName;
|
||||
settings.Profile = _profileName;
|
||||
settings.OutputFile = _outputFile;
|
||||
settings.UseTextureRecompression = true;
|
||||
configureSettings(settings);
|
||||
|
||||
var modLines = _mods.Select(
|
||||
|
@ -16,6 +16,7 @@ using Wabbajack.DTOs;
|
||||
using Wabbajack.DTOs.Directives;
|
||||
using Wabbajack.DTOs.DownloadStates;
|
||||
using Wabbajack.DTOs.JsonConverters;
|
||||
using Wabbajack.FileExtractor.ExtractedFiles;
|
||||
using Wabbajack.Hashing.xxHash64;
|
||||
using Wabbajack.Installer;
|
||||
using Wabbajack.Networking.WabbajackClientApi;
|
||||
@ -120,7 +121,7 @@ public abstract class ACompiler
|
||||
if (OnStatusUpdate != null)
|
||||
OnStatusUpdate(this, new StatusUpdate(statusCategory, statusText,
|
||||
Percent.FactoryPutInRange(_currentStep, MaxSteps),
|
||||
Percent.Zero));
|
||||
Percent.Zero, _currentStep));
|
||||
}
|
||||
|
||||
public void UpdateProgress(long stepProgress)
|
||||
@ -135,7 +136,7 @@ public abstract class ACompiler
|
||||
|
||||
if (OnStatusUpdate != null)
|
||||
OnStatusUpdate(this, new StatusUpdate(_statusCategory, _statusText, Percent.FactoryPutInRange(_currentStep, MaxSteps),
|
||||
Percent.FactoryPutInRange(_currentStepProgress, _maxStepProgress)));
|
||||
Percent.FactoryPutInRange(_currentStepProgress, _maxStepProgress), _currentStep));
|
||||
}
|
||||
|
||||
public void UpdateProgressAbsolute(long cur, long max)
|
||||
@ -151,7 +152,7 @@ public abstract class ACompiler
|
||||
|
||||
if (OnStatusUpdate != null)
|
||||
OnStatusUpdate(this, new StatusUpdate(_statusCategory, _statusText, Percent.FactoryPutInRange(_currentStep, MaxSteps),
|
||||
Percent.FactoryPutInRange(_currentStepProgress, _maxStepProgress)));
|
||||
Percent.FactoryPutInRange(_currentStepProgress, _maxStepProgress), _currentStep));
|
||||
}
|
||||
|
||||
public abstract Task<bool> Begin(CancellationToken token);
|
||||
@ -395,12 +396,15 @@ public abstract class ACompiler
|
||||
|
||||
_settings.OutputFile.Delete();
|
||||
|
||||
var allFiles = _stagingFolder.EnumerateFiles().ToList();
|
||||
NextStep("Finalizing", "Writing Wabbajack File", allFiles.Count);
|
||||
await using (var fs = _settings.OutputFile.Open(FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
using var za = new ZipArchive(fs, ZipArchiveMode.Create);
|
||||
|
||||
foreach (var f in _stagingFolder.EnumerateFiles())
|
||||
foreach (var f in allFiles)
|
||||
{
|
||||
UpdateProgress(1);
|
||||
var ze = za.CreateEntry((string) f.FileName);
|
||||
await using var os = ze.Open();
|
||||
await using var ins = f.Open(FileMode.Open);
|
||||
@ -447,6 +451,12 @@ public abstract class ACompiler
|
||||
/// </summary>
|
||||
protected async Task BuildPatches(CancellationToken token)
|
||||
{
|
||||
await using var tempPath = _manager.CreateFolder();
|
||||
|
||||
AbsolutePath TempPath(Hash file)
|
||||
{
|
||||
return tempPath.Path.Combine(file.ToHex());
|
||||
}
|
||||
|
||||
NextStep("Compiling","Looking for patches");
|
||||
var toBuild = InstallDirectives.OfType<PatchedFromArchive>()
|
||||
@ -455,42 +465,55 @@ public abstract class ACompiler
|
||||
{
|
||||
To = p.To,
|
||||
Hash = p.Hash,
|
||||
FromHash = c.Hash,
|
||||
ArchiveHashPath = c.MakeRelativePaths(),
|
||||
Size = p.Size
|
||||
}))
|
||||
.ToArray();
|
||||
|
||||
NextStep("Compiling","Generating Patches", toBuild.Length);
|
||||
if (toBuild.Length == 0) return;
|
||||
if (toBuild.Any())
|
||||
{
|
||||
|
||||
// Extract all the source files
|
||||
var indexed = toBuild.GroupBy(f => _vfs.Index.FileForArchiveHashPath(f.ArchiveHashPath))
|
||||
.ToDictionary(f => f.Key);
|
||||
await _vfs.Extract(indexed.Keys.ToHashSet(),
|
||||
async (vf, sf) =>
|
||||
NextStep("Compiling", "Generating Patches", toBuild.Length);
|
||||
|
||||
var allFiles = toBuild.SelectMany(f =>
|
||||
{
|
||||
UpdateProgress(1);
|
||||
// For each, extract the destination
|
||||
var matches = indexed[vf];
|
||||
foreach (var match in matches)
|
||||
{
|
||||
var destFile = FindDestFile(match.To);
|
||||
_logger.LogInformation("Patching {from} {to}", destFile, match.To);
|
||||
// Build the patch
|
||||
await _vfs.Extract(new[] {destFile}.ToHashSet(),
|
||||
async (destvf, destsfn) =>
|
||||
return new[]
|
||||
{
|
||||
_vfs.Index.FileForArchiveHashPath(f.ArchiveHashPath),
|
||||
FindDestFile(f.To)
|
||||
};
|
||||
})
|
||||
.DistinctBy(f => f.Hash)
|
||||
.ToHashSet();
|
||||
|
||||
await using var srcStream = await sf.GetStream();
|
||||
await using var destStream = await destsfn.GetStream();
|
||||
using var _ = await CompilerLimiter.Begin($"Patching {match.To}", 100, token);
|
||||
var patchSize =
|
||||
await _patchCache.CreatePatch(srcStream, vf.Hash, destStream, destvf.Hash);
|
||||
_logger.LogInformation("Patch size {patchSize} for {to}", patchSize, match.To);
|
||||
_logger.LogInformation("Extracting {Count} ({Size}) files for building patches", allFiles.Count,
|
||||
allFiles.Sum(f => f.Size).ToFileSizeString());
|
||||
|
||||
NextStep("Compiling", "Extracting Patch Files", allFiles.Count);
|
||||
await _vfs.Extract(allFiles, async (vf, file) =>
|
||||
{
|
||||
UpdateProgress(1);
|
||||
await using var ostream = TempPath(vf.Hash).Open(FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||
await using var istream = await file.GetStream();
|
||||
await istream.CopyToAsync(ostream, token);
|
||||
}, token);
|
||||
}
|
||||
}, token, runInParallel: false);
|
||||
|
||||
if (toBuild.Length == 0) return;
|
||||
|
||||
NextStep("Compiling", "Generating Patch Files", toBuild.Length);
|
||||
await toBuild.PMapAllBatched(CompilerLimiter, async patch =>
|
||||
{
|
||||
UpdateProgress(1);
|
||||
await using var src = TempPath(patch.FromHash).Open(FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
await using var dst = TempPath(patch.Hash).Open(FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
await _patchCache.CreatePatch(src, patch.FromHash, dst, patch.Hash);
|
||||
return patch;
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
NextStep("Compiling", "Loading Patch Files");
|
||||
// Load in the patches
|
||||
await InstallDirectives.OfType<PatchedFromArchive>()
|
||||
.Where(p => p.PatchID == default)
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Compression.BSA;
|
||||
using Wabbajack.DTOs;
|
||||
@ -73,6 +74,8 @@ public class DeconstructBSAs : ACompilationStep
|
||||
"Please re-compress this BSA into a more manageable size.");
|
||||
}
|
||||
|
||||
_compiler._logger.LogInformation("Deconstructing BSA: {Name}", source.File.FullPath.FileName);
|
||||
|
||||
var sourceFiles = source.File.Children;
|
||||
|
||||
var stack = defaultInclude ? _microstackWithInclude(source.File) : _microstack(source.File);
|
||||
@ -86,8 +89,8 @@ public class DeconstructBSAs : ACompilationStep
|
||||
//_cleanup = await source.File.Context.Stage(source.File.Children);
|
||||
}
|
||||
|
||||
var matches = await sourceFiles.PMapAll(_compiler.CompilerLimiter,
|
||||
e => _mo2Compiler.RunStack(stack,
|
||||
var matches = await sourceFiles.SelectAsync(
|
||||
async e => await _mo2Compiler.RunStack(stack,
|
||||
new RawSourceFile(e, Consts.BSACreationDir.Combine(id, (RelativePath) e.Name))))
|
||||
.ToList();
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class MO2Compiler : ACompiler
|
||||
var stack = MakeStack();
|
||||
|
||||
NextStep("Compiling", "Running Compilation Stack", AllFiles.Count);
|
||||
var results = await AllFiles.PMapAll(CompilerLimiter, f =>
|
||||
var results = await AllFiles.PMapAllBatched(CompilerLimiter, f =>
|
||||
{
|
||||
UpdateProgress(1);
|
||||
return RunStack(stack, f);
|
||||
|
@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Data.SQLite;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Compiler.PatchCache;
|
||||
using Wabbajack.Hashing.xxHash64;
|
||||
using Wabbajack.Paths;
|
||||
@ -15,94 +18,63 @@ public class BinaryPatchCache : IBinaryPatchCache
|
||||
private readonly SQLiteConnection _conn;
|
||||
private readonly string _connectionString;
|
||||
private readonly AbsolutePath _location;
|
||||
private readonly ILogger<BinaryPatchCache> _logger;
|
||||
|
||||
public BinaryPatchCache(AbsolutePath location)
|
||||
public BinaryPatchCache(ILogger<BinaryPatchCache> logger, AbsolutePath location)
|
||||
{
|
||||
_logger = logger;
|
||||
_location = location;
|
||||
if (!_location.Parent.DirectoryExists())
|
||||
_location.Parent.CreateDirectory();
|
||||
if (!_location.DirectoryExists())
|
||||
_location.CreateDirectory();
|
||||
}
|
||||
|
||||
_connectionString =
|
||||
string.Intern($"URI=file:{location.ToString()};Pooling=True;Max Pool Size=100; Journal Mode=Memory;");
|
||||
_conn = new SQLiteConnection(_connectionString);
|
||||
_conn.Open();
|
||||
|
||||
using var cmd = new SQLiteCommand(_conn);
|
||||
cmd.CommandText = @"CREATE TABLE IF NOT EXISTS PatchCache (
|
||||
FromHash BIGINT,
|
||||
ToHash BIGINT,
|
||||
PatchSize BLOB,
|
||||
Patch BLOB,
|
||||
PRIMARY KEY (FromHash, ToHash))
|
||||
WITHOUT ROWID;";
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
public AbsolutePath PatchLocation(Hash srcHash, Hash destHash)
|
||||
{
|
||||
return _location.Combine($"{srcHash.ToHex()}_{destHash.ToHex()}.octodiff");
|
||||
}
|
||||
|
||||
public async Task<CacheEntry> CreatePatch(Stream srcStream, Hash srcHash, Stream destStream, Hash destHash, IJob? job)
|
||||
{
|
||||
await using var rcmd = new SQLiteCommand(_conn);
|
||||
rcmd.CommandText = "SELECT PatchSize FROM PatchCache WHERE FromHash = @fromHash AND ToHash = @toHash";
|
||||
rcmd.Parameters.AddWithValue("@fromHash", (long) srcHash);
|
||||
rcmd.Parameters.AddWithValue("@toHash", (long) destHash);
|
||||
|
||||
await using var rdr = await rcmd.ExecuteReaderAsync();
|
||||
while (await rdr.ReadAsync()) return new CacheEntry(srcHash, destHash, rdr.GetInt64(0), this);
|
||||
|
||||
await using var cmd = new SQLiteCommand(_conn);
|
||||
cmd.CommandText = @"INSERT INTO PatchCache (FromHash, ToHash, PatchSize, Patch)
|
||||
VALUES (@fromHash, @toHash, @patchSize, @patch)";
|
||||
|
||||
cmd.Parameters.AddWithValue("@fromHash", (long) srcHash);
|
||||
cmd.Parameters.AddWithValue("@toHash", (long) destHash);
|
||||
var location = PatchLocation(srcHash, destHash);
|
||||
if (location.FileExists())
|
||||
return new CacheEntry(srcHash, destHash, location.Size(), this);
|
||||
|
||||
await using var sigStream = new MemoryStream();
|
||||
await using var patchStream = new MemoryStream();
|
||||
OctoDiff.Create(srcStream, destStream, sigStream, patchStream, job);
|
||||
|
||||
cmd.Parameters.AddWithValue("@patchSize", patchStream.Length);
|
||||
cmd.Parameters.AddWithValue("@patch", patchStream.ToArray());
|
||||
var tempName = _location.Combine(Guid.NewGuid().ToString()).WithExtension(Ext.Temp);
|
||||
await using var patchStream = tempName.Open(FileMode.Create, FileAccess.ReadWrite, FileShare.None);
|
||||
try
|
||||
{
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
OctoDiff.Create(srcStream, destStream, sigStream, patchStream, job);
|
||||
|
||||
patchStream.Close();
|
||||
await tempName.MoveToAsync(location, true, CancellationToken.None);
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
finally
|
||||
{
|
||||
if (!ex.Message.StartsWith("constraint failed"))
|
||||
throw;
|
||||
await patchStream.DisposeAsync();
|
||||
if (tempName.FileExists())
|
||||
tempName.Delete();
|
||||
}
|
||||
|
||||
return new CacheEntry(srcHash, destHash, patchStream.Length, this);
|
||||
return new CacheEntry(srcHash, destHash, location.Size(), this);
|
||||
}
|
||||
|
||||
|
||||
public async Task<CacheEntry?> GetPatch(Hash fromHash, Hash toHash)
|
||||
{
|
||||
await using var cmd = new SQLiteCommand(_conn);
|
||||
cmd.CommandText = @"SELECT PatchSize FROM PatchCache WHERE FromHash = @fromHash AND ToHash = @toHash";
|
||||
cmd.Parameters.AddWithValue("@fromHash", (long) fromHash);
|
||||
cmd.Parameters.AddWithValue("@toHash", (long) toHash);
|
||||
|
||||
await using var rdr = await cmd.ExecuteReaderAsync();
|
||||
while (await rdr.ReadAsync()) return new CacheEntry(fromHash, toHash, rdr.GetInt64(0), this);
|
||||
var location = PatchLocation(fromHash, toHash);
|
||||
if (location.FileExists())
|
||||
return new CacheEntry(fromHash, toHash, location.Size(), this);
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<byte[]> GetData(CacheEntry entry)
|
||||
{
|
||||
await using var cmd = new SQLiteCommand(_conn);
|
||||
cmd.CommandText = @"SELECT PatchSize, Patch FROM PatchCache WHERE FromHash = @fromHash AND ToHash = @toHash";
|
||||
cmd.Parameters.AddWithValue("@fromHash", (long) entry.From);
|
||||
cmd.Parameters.AddWithValue("@toHash", (long) entry.To);
|
||||
|
||||
await using var rdr = await cmd.ExecuteReaderAsync();
|
||||
while (await rdr.ReadAsync())
|
||||
{
|
||||
var array = new byte[rdr.GetInt64(0)];
|
||||
rdr.GetBytes(1, 0, array, 0, array.Length);
|
||||
return array;
|
||||
}
|
||||
|
||||
var location = PatchLocation(entry.From, entry.To);
|
||||
if (location.FileExists())
|
||||
return await location.ReadAllBytesAsync();
|
||||
return Array.Empty<byte>();
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ public static class GameRegistry
|
||||
|
||||
public static GameMetaData? GetByMO2ArchiveName(string gameName)
|
||||
{
|
||||
return Games.Values.FirstOrDefault(g => (g.MO2ArchiveName ?? g.NexusName)!.Equals(gameName, StringComparison.InvariantCultureIgnoreCase));
|
||||
return Games.Values.FirstOrDefault(g => (g.MO2ArchiveName ?? g.NexusName ?? "")!.Equals(gameName, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
public static GameMetaData? GetByNexusName(string gameName)
|
||||
|
@ -13,7 +13,6 @@ using OMODFramework;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.FileSignatures;
|
||||
using Wabbajack.Compression.BSA;
|
||||
using Wabbajack.Compression.BSA.FO4Archive;
|
||||
using Wabbajack.DTOs.Streams;
|
||||
using Wabbajack.FileExtractor.ExtractedFiles;
|
||||
using Wabbajack.IO.Async;
|
||||
@ -343,8 +342,8 @@ public class FileExtractor
|
||||
|
||||
if (!int.TryParse(line[..3], out var percentInt)) return;
|
||||
|
||||
var oldPosition = lastPercent == 0 ? 0 : totalSize / lastPercent;
|
||||
var newPosition = percentInt == 0 ? 0 : totalSize / percentInt;
|
||||
var oldPosition = lastPercent == 0 ? 0 : totalSize / 100 * lastPercent;
|
||||
var newPosition = percentInt == 0 ? 0 : totalSize / 100 * percentInt;
|
||||
var throughput = newPosition - oldPosition;
|
||||
job.ReportNoWait((int) throughput);
|
||||
|
||||
|
@ -26,7 +26,7 @@ using Wabbajack.VFS;
|
||||
|
||||
namespace Wabbajack.Installer;
|
||||
|
||||
public record StatusUpdate(string StatusCategory, string StatusText, Percent StepsProgress, Percent StepProgress)
|
||||
public record StatusUpdate(string StatusCategory, string StatusText, Percent StepsProgress, Percent StepProgress, int CurrentStep)
|
||||
{
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public abstract class AInstaller<T>
|
||||
_logger.LogInformation("Next Step: {Step}", statusText);
|
||||
|
||||
OnStatusUpdate?.Invoke(new StatusUpdate(statusCategory, statusText,
|
||||
Percent.FactoryPutInRange(_currentStep, MaxSteps), Percent.Zero));
|
||||
Percent.FactoryPutInRange(_currentStep, MaxSteps), Percent.Zero, _currentStep));
|
||||
}
|
||||
|
||||
public void UpdateProgress(long stepProgress)
|
||||
@ -122,7 +122,7 @@ public abstract class AInstaller<T>
|
||||
|
||||
OnStatusUpdate?.Invoke(new StatusUpdate(_statusCategory, $"[{_currentStep}/{MaxSteps}] {_statusText} ({_statusFormatter(_currentStepProgress)}/{_statusFormatter(MaxStepProgress)})",
|
||||
Percent.FactoryPutInRange(_currentStep, MaxSteps),
|
||||
Percent.FactoryPutInRange(_currentStepProgress, MaxStepProgress)));
|
||||
Percent.FactoryPutInRange(_currentStepProgress, MaxStepProgress), _currentStep));
|
||||
}
|
||||
|
||||
public abstract Task<bool> Begin(CancellationToken token);
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Wabbajack.Paths.IO;
|
||||
@ -13,8 +14,15 @@ public static class KnownFolders
|
||||
{
|
||||
var result = Process.GetCurrentProcess().MainModule?.FileName?.ToAbsolutePath() ?? default;
|
||||
|
||||
if (result != default &&
|
||||
result.PathParts.Any(p => p.Equals("TestRunner", StringComparison.CurrentCultureIgnoreCase)))
|
||||
{
|
||||
return Assembly.GetExecutingAssembly().Location.ToAbsolutePath().Parent;
|
||||
}
|
||||
|
||||
if ((result != default && result.Depth > 1 && result.FileName == "dotnet".ToRelativePath()) || Assembly.GetEntryAssembly() != null)
|
||||
|
||||
if ((result != default && result.Depth > 1 && result.FileName == "dotnet".ToRelativePath())
|
||||
|| Assembly.GetEntryAssembly() != null)
|
||||
{
|
||||
result = Assembly.GetEntryAssembly()!.Location.ToAbsolutePath();
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ public struct AbsolutePath : IPath, IComparable<AbsolutePath>, IEquatable<Absolu
|
||||
|
||||
internal readonly string[] Parts;
|
||||
|
||||
public string[] PathParts => Parts == default ? Array.Empty<string>() : Parts;
|
||||
|
||||
public Extension Extension => Extension.FromPath(Parts[^1]);
|
||||
public RelativePath FileName => new(Parts[^1..]);
|
||||
|
||||
@ -153,7 +155,7 @@ public struct AbsolutePath : IPath, IComparable<AbsolutePath>, IEquatable<Absolu
|
||||
return ArrayExtensions.AreEqualIgnoreCase(parent.Parts, 0, Parts, 0, parent.Parts.Length);
|
||||
}
|
||||
|
||||
public AbsolutePath Combine(params object[] paths)
|
||||
public readonly AbsolutePath Combine(params object[] paths)
|
||||
{
|
||||
var converted = paths.Select(p =>
|
||||
{
|
||||
|
@ -69,8 +69,8 @@ public static class ServiceExtensions
|
||||
});
|
||||
|
||||
service.AddSingleton<IBinaryPatchCache>(s => options.UseLocalCache
|
||||
? new BinaryPatchCache(s.GetService<TemporaryFileManager>()!.CreateFile().Path)
|
||||
: new BinaryPatchCache(KnownFolders.WabbajackAppLocal.Combine("patchCache.sqlite")));
|
||||
? new BinaryPatchCache(s.GetRequiredService<ILogger<BinaryPatchCache>>(), s.GetService<TemporaryFileManager>()!.CreateFolder().Path)
|
||||
: new BinaryPatchCache(s.GetRequiredService<ILogger<BinaryPatchCache>>(),KnownFolders.WabbajackAppLocal.Combine("PatchCache")));
|
||||
|
||||
service.AddSingleton(new ParallelOptions {MaxDegreeOfParallelism = Environment.ProcessorCount});
|
||||
|
||||
|
@ -7,8 +7,8 @@ mkdir c:\tmp\publish-wj
|
||||
|
||||
dotnet clean
|
||||
dotnet restore
|
||||
dotnet publish Wabbajack.App.Wpf\Wabbajack.App.Wpf.csproj --runtime win10-x64 --configuration Release /p:Platform=x64 -o c:\tmp\publish-wj\app /p:PublishedTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained
|
||||
dotnet publish Wabbajack.Launcher\Wabbajack.Launcher.csproj --runtime win10-x64 --configuration Release /p:Platform=x64 -o c:\tmp\publish-wj\launcher /p:PublishedTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained
|
||||
dotnet publish Wabbajack.App.Wpf\Wabbajack.App.Wpf.csproj --runtime win10-x64 --configuration Release /p:Platform=x64 -o c:\tmp\publish-wj\app /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained
|
||||
dotnet publish Wabbajack.Launcher\Wabbajack.Launcher.csproj --runtime win10-x64 --configuration Release /p:Platform=x64 -o c:\tmp\publish-wj\launcher /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained
|
||||
dotnet publish c:\oss\Wabbajack\Wabbajack.CLI\Wabbajack.CLI.csproj --runtime win10-x64 --configuration Release /p:Platform=x64 -o c:\tmp\publish-wj\app --self-contained
|
||||
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe" sign /t http://timestamp.sectigo.com c:\tmp\publish-wj\app\Wabbajack.exe
|
||||
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe" sign /t http://timestamp.sectigo.com c:\tmp\publish-wj\launcher\Wabbajack.exe
|
||||
|
Loading…
Reference in New Issue
Block a user