mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #1162 from wabbajack-tools/better-status-update
More fine-grained status updates
This commit is contained in:
commit
d00d66a269
@ -7,7 +7,7 @@ namespace Wabbajack.Common
|
||||
public class StatusUpdateTracker
|
||||
{
|
||||
private Subject<string> _stepName = new Subject<string>();
|
||||
public IObservable<string> StepName => _stepName;
|
||||
public IObservable<string> StepName => _stepName.Debounce(TimeSpan.FromMilliseconds(100));
|
||||
|
||||
private Subject<int> _step = new Subject<int>();
|
||||
public IObservable<int> Step => _step;
|
||||
@ -20,6 +20,7 @@ namespace Wabbajack.Common
|
||||
|
||||
private int _internalCurrentStep;
|
||||
private int _internalMaxStep;
|
||||
private string _currentStepName = "";
|
||||
|
||||
public StatusUpdateTracker(int maxStep)
|
||||
{
|
||||
@ -33,10 +34,11 @@ namespace Wabbajack.Common
|
||||
|
||||
public void NextStep(string name)
|
||||
{
|
||||
_currentStepName = name;
|
||||
_internalCurrentStep += 1;
|
||||
Utils.Log(name);
|
||||
_step.OnNext(_internalCurrentStep);
|
||||
_stepName.OnNext(name);
|
||||
_stepName.OnNext($"({_internalCurrentStep}/{_internalMaxStep}) {_currentStepName}");
|
||||
MakeUpdate(Percent.Zero);
|
||||
}
|
||||
|
||||
@ -62,6 +64,7 @@ namespace Wabbajack.Common
|
||||
public void MakeUpdate(int max, int curr)
|
||||
{
|
||||
MakeUpdate(Percent.FactoryPutInRange(curr, max == 0 ? 1 : max));
|
||||
_stepName.OnNext($"({_internalCurrentStep}/{_internalMaxStep}) {_currentStepName}, {curr} of {max}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ namespace Wabbajack.Lib
|
||||
await file.To.RelativeTo(OutputFolder).Compact(FileCompaction.Algorithm.XPRESS16K);
|
||||
}
|
||||
}
|
||||
}, tempFolder: OutputFolder);
|
||||
}, tempFolder: OutputFolder, updateTracker: UpdateTracker);
|
||||
}
|
||||
|
||||
public async Task DownloadArchives()
|
||||
@ -211,7 +211,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
DesiredThreads.OnNext(DownloadThreads);
|
||||
await missing.Where(a => a.State.GetType() != typeof(ManualDownloader.State))
|
||||
.PMap(Queue, async archive =>
|
||||
.PMap(Queue, UpdateTracker, async archive =>
|
||||
{
|
||||
Info($"Downloading {archive.Name}");
|
||||
var outputPath = DownloadFolder.Combine(archive.Name);
|
||||
@ -268,7 +268,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
var hashResults = await
|
||||
toHash
|
||||
.PMap(Queue, async e => (await e.FileHashCachedAsync(), e));
|
||||
.PMap(Queue, UpdateTracker,async e => (await e.FileHashCachedAsync(), e));
|
||||
|
||||
HashedArchives.SetTo(hashResults
|
||||
.OrderByDescending(e => e.Item2.LastModified)
|
||||
@ -385,9 +385,6 @@ namespace Wabbajack.Lib
|
||||
var path = OutputFolder.Combine(d.To);
|
||||
if (!existingfiles.Contains(path)) return null;
|
||||
|
||||
if (path.Size != d.Size) return null;
|
||||
Status($"Optimizing {d.To}");
|
||||
|
||||
return await path.FileHashCachedAsync() == d.Hash ? d : null;
|
||||
}))
|
||||
.Do(d =>
|
||||
|
@ -202,7 +202,7 @@ namespace Wabbajack.Lib
|
||||
// Find all Downloads
|
||||
IndexedArchives = (await DownloadsPath.EnumerateFiles()
|
||||
.Where(f => f.WithExtension(Consts.MetaFileExtension).Exists)
|
||||
.PMap(Queue,
|
||||
.PMap(Queue, UpdateTracker,
|
||||
async f => new IndexedArchive(VFS.Index.ByRootPath[f])
|
||||
{
|
||||
Name = (string)f.FileName,
|
||||
|
@ -257,7 +257,7 @@ namespace Wabbajack.Lib
|
||||
private async Task InstallIncludedDownloadMetas()
|
||||
{
|
||||
await ModList.Archives
|
||||
.PMap(Queue, async archive =>
|
||||
.PMap(Queue, UpdateTracker, async archive =>
|
||||
{
|
||||
if (HashedArchives.TryGetValue(archive.Hash, out var paths))
|
||||
{
|
||||
@ -313,7 +313,7 @@ namespace Wabbajack.Lib
|
||||
var bsaSize = bsa.FileStates.Select(state => sourceDir.Combine(state.Path).Size).Sum();
|
||||
|
||||
await using var a = await bsa.State.MakeBuilder(bsaSize);
|
||||
var streams = await bsa.FileStates.PMap(Queue, async state =>
|
||||
var streams = await bsa.FileStates.PMap(Queue, UpdateTracker, async state =>
|
||||
{
|
||||
Status($"Adding {state.Path} to BSA");
|
||||
var fs = await sourceDir.Combine(state.Path).OpenRead();
|
||||
@ -344,7 +344,7 @@ namespace Wabbajack.Lib
|
||||
Info("Writing inline files");
|
||||
await ModList.Directives
|
||||
.OfType<InlineFile>()
|
||||
.PMap(Queue, async directive =>
|
||||
.PMap(Queue, UpdateTracker, async directive =>
|
||||
{
|
||||
Status($"Writing included file {directive.To}");
|
||||
var outPath = OutputFolder.Combine(directive.To);
|
||||
|
@ -209,7 +209,7 @@ namespace Wabbajack.VirtualFileSystem
|
||||
/// <param name="files"></param>
|
||||
/// <param name="callback"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Extract(WorkQueue queue, HashSet<VirtualFile> files, Func<VirtualFile, IExtractedFile, ValueTask> callback, AbsolutePath? tempFolder = null)
|
||||
public async Task Extract(WorkQueue queue, HashSet<VirtualFile> files, Func<VirtualFile, IExtractedFile, ValueTask> callback, AbsolutePath? tempFolder = null, StatusUpdateTracker updateTracker = null)
|
||||
{
|
||||
var top = new VirtualFile();
|
||||
var filesByParent = files.SelectMany(f => f.FilesInFullPath)
|
||||
@ -251,7 +251,8 @@ namespace Wabbajack.VirtualFileSystem
|
||||
}
|
||||
|
||||
}
|
||||
await filesByParent[top].PMap(queue, async file => await HandleFile(file, new ExtractedNativeFile(file.AbsoluteName) {CanMove = false}));
|
||||
updateTracker ??= new StatusUpdateTracker(1);
|
||||
await filesByParent[top].PMap(queue, updateTracker, async file => await HandleFile(file, new ExtractedNativeFile(file.AbsoluteName) {CanMove = false}));
|
||||
}
|
||||
|
||||
#region KnownFiles
|
||||
|
@ -306,6 +306,9 @@ namespace Wabbajack
|
||||
if (err) return "Corrupted Modlist";
|
||||
return name;
|
||||
})
|
||||
.Merge(this.WhenAny(x => x.Installer.ActiveInstallation)
|
||||
.Where(c => c != null)
|
||||
.SelectMany(c => c.TextStatus))
|
||||
.ToGuiProperty(this, nameof(ModListName));
|
||||
|
||||
ShowManifestCommand = ReactiveCommand.Create(() =>
|
||||
|
Loading…
Reference in New Issue
Block a user