mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
commit
f54890b7aa
@ -354,6 +354,34 @@ namespace Wabbajack.Lib
|
|||||||
File.Delete(f);
|
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");
|
UpdateTracker.NextStep("Looking for unmodified files");
|
||||||
(await indexed.Values.PMap(Queue, UpdateTracker, d =>
|
(await indexed.Values.PMap(Queue, UpdateTracker, d =>
|
||||||
{
|
{
|
||||||
@ -372,33 +400,6 @@ namespace Wabbajack.Lib
|
|||||||
.Where(d => d != null)
|
.Where(d => d != null)
|
||||||
.Do(d => indexed.Remove(d.To));
|
.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");
|
UpdateTracker.NextStep("Updating ModList");
|
||||||
Utils.Log($"Optimized {ModList.Directives.Count} directives to {indexed.Count} required");
|
Utils.Log($"Optimized {ModList.Directives.Count} directives to {indexed.Count} required");
|
||||||
var requiredArchives = indexed.Values.OfType<FromArchive>()
|
var requiredArchives = indexed.Values.OfType<FromArchive>()
|
||||||
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
|||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
|
using Wabbajack.Common.StatusFeed;
|
||||||
using Wabbajack.Lib;
|
using Wabbajack.Lib;
|
||||||
using Wabbajack.Util;
|
using Wabbajack.Util;
|
||||||
|
|
||||||
@ -105,7 +106,8 @@ namespace Wabbajack
|
|||||||
.DisposeWith(CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
|
|
||||||
// Hook onto user interventions, and intercept MO2 specific ones for customization
|
// 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<IStatusMessage>())
|
||||||
.Switch()
|
.Switch()
|
||||||
.Subscribe(x =>
|
.Subscribe(x =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user