From 4c842fe276211b3f8d1daaa76a84c729aed42160 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 8 Feb 2020 00:16:49 -0600 Subject: [PATCH 1/2] Added short circuit of MO2Installer interventions So that new active installations replace any old pending queues --- Wabbajack/View Models/Installers/MO2InstallerVM.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Wabbajack/View Models/Installers/MO2InstallerVM.cs b/Wabbajack/View Models/Installers/MO2InstallerVM.cs index 180147e6..d39f82cb 100644 --- a/Wabbajack/View Models/Installers/MO2InstallerVM.cs +++ b/Wabbajack/View Models/Installers/MO2InstallerVM.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using ReactiveUI; using ReactiveUI.Fody.Helpers; using Wabbajack.Common; +using Wabbajack.Common.StatusFeed; using Wabbajack.Lib; using Wabbajack.Util; @@ -105,7 +106,8 @@ namespace Wabbajack .DisposeWith(CompositeDisposable); // Hook onto user interventions, and intercept MO2 specific ones for customization - this.WhenAny(x => x.ActiveInstallation.LogMessages) + this.WhenAny(x => x.ActiveInstallation) + .Select(x => x?.LogMessages ?? Observable.Empty()) .Switch() .Subscribe(x => { From d96a1d3f0e093989520dda62582ee2487f4a0700 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 8 Feb 2020 13:25:49 -0600 Subject: [PATCH 2/2] AInstaller.OptimizeModlist: Moved expected folders logic before trimming #490 --- Wabbajack.Lib/AInstaller.cs | 55 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/Wabbajack.Lib/AInstaller.cs b/Wabbajack.Lib/AInstaller.cs index 29e870fa..c171c760 100644 --- a/Wabbajack.Lib/AInstaller.cs +++ b/Wabbajack.Lib/AInstaller.cs @@ -354,6 +354,34 @@ namespace Wabbajack.Lib File.Delete(f); }); + Utils.Log("Cleaning empty folders"); + var expectedFolders = indexed.Keys + // We ignore the last part of the path, so we need a dummy file name + .Append(Path.Combine(DownloadFolder, "_")) + .SelectMany(path => + { + // Get all the folders and all the folder parents + // so for foo\bar\baz\qux.txt this emits ["foo", "foo\\bar", "foo\\bar\\baz"] + var split = path.Split('\\'); + return Enumerable.Range(1, split.Length - 1).Select(t => string.Join("\\", split.Take(t))); + }) + .Distinct() + .Select(p => Path.Combine(OutputFolder, p)) + .ToHashSet(); + + try + { + Directory.EnumerateDirectories(OutputFolder, DirectoryEnumerationOptions.Recursive) + .Where(p => !expectedFolders.Contains(p)) + .OrderByDescending(p => p.Length) + .Do(Utils.DeleteDirectory); + } + catch (Exception) + { + // ignored because it's not worth throwing a fit over + Utils.Log("Error when trying to clean empty folders. This doesn't really matter."); + } + UpdateTracker.NextStep("Looking for unmodified files"); (await indexed.Values.PMap(Queue, UpdateTracker, d => { @@ -372,33 +400,6 @@ namespace Wabbajack.Lib .Where(d => d != null) .Do(d => indexed.Remove(d.To)); - Utils.Log("Cleaning empty folders"); - var expectedFolders = indexed.Keys - // We ignore the last part of the path, so we need a dummy file name - .Append(Path.Combine(DownloadFolder, "_")) - .SelectMany(path => - { - // Get all the folders and all the folder parents - // so for foo\bar\baz\qux.txt this emits ["foo", "foo\\bar", "foo\\bar\\baz"] - var split = path.Split('\\'); - return Enumerable.Range(1, split.Length - 1).Select(t => string.Join("\\", split.Take(t))); - }).Distinct() - .Select(p => Path.Combine(OutputFolder, p)) - .ToHashSet(); - - try - { - Directory.EnumerateDirectories(OutputFolder, DirectoryEnumerationOptions.Recursive) - .Where(p => !expectedFolders.Contains(p)) - .OrderByDescending(p => p.Length) - .Do(Utils.DeleteDirectory); - } - catch (Exception) - { - // ignored because it's not worth throwing a fit over - Utils.Log("Error when trying to clean empty folders. This doesn't really matter."); - } - UpdateTracker.NextStep("Updating ModList"); Utils.Log($"Optimized {ModList.Directives.Count} directives to {indexed.Count} required"); var requiredArchives = indexed.Values.OfType()