diff --git a/Compression.BSA.Test/BSATests.cs b/Compression.BSA.Test/BSATests.cs index 48587564..220a255d 100644 --- a/Compression.BSA.Test/BSATests.cs +++ b/Compression.BSA.Test/BSATests.cs @@ -65,7 +65,7 @@ namespace Compression.BSA.Test { var filename = await DownloadMod(game, modid); var folder = _bsaFolder.Combine(game.ToString(), modid.ToString()); - folder.DeleteDirectory(); + await folder.DeleteDirectory(); folder.CreateDirectory(); await FileExtractor.ExtractAll(Queue, filename, folder); @@ -73,7 +73,7 @@ namespace Compression.BSA.Test { TestContext.WriteLine($"From {bsa}"); TestContext.WriteLine("Cleaning Output Dir"); - _tempDir.DeleteDirectory(); + await _tempDir.DeleteDirectory(); _tempDir.CreateDirectory(); TestContext.WriteLine($"Reading {bsa}"); diff --git a/Wabbajack.Common/Paths.cs b/Wabbajack.Common/Paths.cs index 21a46f2d..5b56c1e8 100644 --- a/Wabbajack.Common/Paths.cs +++ b/Wabbajack.Common/Paths.cs @@ -132,11 +132,11 @@ namespace Wabbajack.Common public bool IsFile => File.Exists(_path); public bool IsDirectory => Directory.Exists(_path); - public void DeleteDirectory() + public async Task DeleteDirectory() { if (IsDirectory) { - Utils.DeleteDirectory(this); + await Utils.DeleteDirectory(this); } } diff --git a/Wabbajack.Common/Util/TempFolder.cs b/Wabbajack.Common/Util/TempFolder.cs index 6674565b..caa7902f 100644 --- a/Wabbajack.Common/Util/TempFolder.cs +++ b/Wabbajack.Common/Util/TempFolder.cs @@ -34,7 +34,7 @@ namespace Wabbajack.Common { if (DeleteAfter && Dir.Exists) { - Utils.DeleteDirectory(Dir); + Utils.DeleteDirectory(Dir).Wait(); } } } diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index 5be6d068..000d3785 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -968,7 +968,7 @@ namespace Wabbajack.Common /// delete a folder. If you don't like this code, it's unlikely to change without a ton of testing. /// /// - public static async void DeleteDirectory(AbsolutePath path) + public static async Task DeleteDirectory(AbsolutePath path) { var process = new ProcessHelper { diff --git a/Wabbajack.Lib/AInstaller.cs b/Wabbajack.Lib/AInstaller.cs index aa252c46..21d4927e 100644 --- a/Wabbajack.Lib/AInstaller.cs +++ b/Wabbajack.Lib/AInstaller.cs @@ -364,10 +364,14 @@ namespace Wabbajack.Lib try { - OutputFolder.EnumerateDirectories(true) + var toDelete = OutputFolder.EnumerateDirectories(true) .Where(p => !expectedFolders.Contains(p)) - .OrderByDescending(p => p.Size) - .Do(Utils.DeleteDirectory); + .OrderByDescending(p => ((string)p).Length) + .ToList(); + foreach (var dir in toDelete) + { + await dir.DeleteDirectory(); + } } catch (Exception) { diff --git a/Wabbajack.Lib/MO2Compiler.cs b/Wabbajack.Lib/MO2Compiler.cs index d01dc66e..c9698e0a 100644 --- a/Wabbajack.Lib/MO2Compiler.cs +++ b/Wabbajack.Lib/MO2Compiler.cs @@ -152,7 +152,7 @@ namespace Wabbajack.Lib if (cancel.IsCancellationRequested) return false; UpdateTracker.NextStep("Cleaning output folder"); - ModListOutputFolder.DeleteDirectory(); + await ModListOutputFolder.DeleteDirectory(); if (cancel.IsCancellationRequested) return false; UpdateTracker.NextStep("Inferring metas for game file downloads"); diff --git a/Wabbajack.Lib/MO2Installer.cs b/Wabbajack.Lib/MO2Installer.cs index 1f30867a..4d58bb36 100644 --- a/Wabbajack.Lib/MO2Installer.cs +++ b/Wabbajack.Lib/MO2Installer.cs @@ -276,7 +276,7 @@ namespace Wabbajack.Lib if (bsaDir.Exists) { Info($"Removing temp folder {Consts.BSACreationDir}"); - Utils.DeleteDirectory(bsaDir); + await Utils.DeleteDirectory(bsaDir); } } diff --git a/Wabbajack.Lib/VortexCompiler.cs b/Wabbajack.Lib/VortexCompiler.cs index e7ee252e..85c80628 100644 --- a/Wabbajack.Lib/VortexCompiler.cs +++ b/Wabbajack.Lib/VortexCompiler.cs @@ -111,7 +111,7 @@ namespace Wabbajack.Lib if (cancel.IsCancellationRequested) return false; UpdateTracker.NextStep("Cleaning output folder"); - ModListOutputFolder.DeleteDirectory(); + await ModListOutputFolder.DeleteDirectory(); ModListOutputFolder.CreateDirectory(); UpdateTracker.NextStep("Finding Install Files"); diff --git a/Wabbajack.Test/DownloaderTests.cs b/Wabbajack.Test/DownloaderTests.cs index 437b5640..0a22b66b 100644 --- a/Wabbajack.Test/DownloaderTests.cs +++ b/Wabbajack.Test/DownloaderTests.cs @@ -500,7 +500,7 @@ namespace Wabbajack.Test }; var folder = ((RelativePath)"DownloadTests").RelativeToEntryPoint(); - folder.DeleteDirectory(); + await folder.DeleteDirectory(); folder.CreateDirectory(); var inst = new TestInstaller(default, null, default, folder, null); diff --git a/Wabbajack.sln b/Wabbajack.sln index eb8e9c6a..1c53697c 100644 --- a/Wabbajack.sln +++ b/Wabbajack.sln @@ -54,32 +54,36 @@ Global {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|Any CPU.ActiveCfg = Release|x64 {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|x64.ActiveCfg = Release|x64 {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|x64.Build.0 = Release|x64 + {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug|Any CPU.Build.0 = Debug|x64 {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug|Any CPU.ActiveCfg = Debug|x64 {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug|x64.ActiveCfg = Debug|x64 {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug|x64.Build.0 = Debug|x64 {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|Any CPU.ActiveCfg = Release|x64 {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|x64.ActiveCfg = Release|x64 {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|x64.Build.0 = Release|x64 + {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug|Any CPU.Build.0 = Debug|x64 {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug|Any CPU.ActiveCfg = Debug|x64 {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug|x64.ActiveCfg = Debug|x64 {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug|x64.Build.0 = Debug|x64 {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Release|Any CPU.ActiveCfg = Release|x64 {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Release|x64.ActiveCfg = Release|x64 {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Release|x64.Build.0 = Release|x64 + {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug|Any CPU.Build.0 = Debug|x64 {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug|Any CPU.ActiveCfg = Debug|x64 {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug|x64.ActiveCfg = Debug|x64 {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug|x64.Build.0 = Debug|x64 {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Release|Any CPU.ActiveCfg = Release|x64 {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Release|x64.ActiveCfg = Release|x64 {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Release|x64.Build.0 = Release|x64 + {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug|Any CPU.Build.0 = Debug|x64 {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug|Any CPU.ActiveCfg = Debug|x64 {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug|x64.ActiveCfg = Debug|x64 {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug|x64.Build.0 = Debug|x64 {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Release|Any CPU.ActiveCfg = Release|x64 {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Release|x64.ActiveCfg = Release|x64 {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Release|x64.Build.0 = Release|x64 + {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug|Any CPU.Build.0 = Debug|x64 {DE18D89E-39C5-48FD-8E42-16235E3C4593}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DE18D89E-39C5-48FD-8E42-16235E3C4593}.Debug|Any CPU.Build.0 = Debug|Any CPU {DE18D89E-39C5-48FD-8E42-16235E3C4593}.Debug|x64.ActiveCfg = Debug|Any CPU {DE18D89E-39C5-48FD-8E42-16235E3C4593}.Debug|x64.Build.0 = Debug|Any CPU {DE18D89E-39C5-48FD-8E42-16235E3C4593}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -98,24 +102,28 @@ Global {89281BA1-67C8-48D2-9D6E-0F5CC85AD8C9}.Release|Any CPU.ActiveCfg = Release|x64 {89281BA1-67C8-48D2-9D6E-0F5CC85AD8C9}.Release|x64.ActiveCfg = Release|x64 {89281BA1-67C8-48D2-9D6E-0F5CC85AD8C9}.Release|x64.Build.0 = Release|x64 + {89281BA1-67C8-48D2-9D6E-0F5CC85AD8C9}.Debug|Any CPU.Build.0 = Debug|x64 {F72C17EC-0881-4455-8B0E-E1CC4FFD642E}.Debug|Any CPU.ActiveCfg = Debug|x64 {F72C17EC-0881-4455-8B0E-E1CC4FFD642E}.Debug|x64.ActiveCfg = Debug|x64 {F72C17EC-0881-4455-8B0E-E1CC4FFD642E}.Debug|x64.Build.0 = Debug|x64 {F72C17EC-0881-4455-8B0E-E1CC4FFD642E}.Release|Any CPU.ActiveCfg = Release|x64 {F72C17EC-0881-4455-8B0E-E1CC4FFD642E}.Release|x64.ActiveCfg = Release|x64 {F72C17EC-0881-4455-8B0E-E1CC4FFD642E}.Release|x64.Build.0 = Release|x64 + {F72C17EC-0881-4455-8B0E-E1CC4FFD642E}.Debug|Any CPU.Build.0 = Debug|x64 {81F87B8B-D5CE-4807-9005-38DE95BD7840}.Debug|Any CPU.ActiveCfg = Debug|x64 {81F87B8B-D5CE-4807-9005-38DE95BD7840}.Debug|x64.ActiveCfg = Debug|x64 {81F87B8B-D5CE-4807-9005-38DE95BD7840}.Debug|x64.Build.0 = Debug|x64 {81F87B8B-D5CE-4807-9005-38DE95BD7840}.Release|Any CPU.ActiveCfg = Release|x64 {81F87B8B-D5CE-4807-9005-38DE95BD7840}.Release|x64.ActiveCfg = Release|x64 {81F87B8B-D5CE-4807-9005-38DE95BD7840}.Release|x64.Build.0 = Release|x64 + {81F87B8B-D5CE-4807-9005-38DE95BD7840}.Debug|Any CPU.Build.0 = Debug|x64 {685D8BB1-D178-4D2C-85C7-C54A36FB7454}.Debug|Any CPU.ActiveCfg = Debug|x64 {685D8BB1-D178-4D2C-85C7-C54A36FB7454}.Debug|x64.ActiveCfg = Debug|x64 {685D8BB1-D178-4D2C-85C7-C54A36FB7454}.Debug|x64.Build.0 = Debug|x64 {685D8BB1-D178-4D2C-85C7-C54A36FB7454}.Release|Any CPU.ActiveCfg = Release|x64 {685D8BB1-D178-4D2C-85C7-C54A36FB7454}.Release|x64.ActiveCfg = Release|x64 {685D8BB1-D178-4D2C-85C7-C54A36FB7454}.Release|x64.Build.0 = Release|x64 + {685D8BB1-D178-4D2C-85C7-C54A36FB7454}.Debug|Any CPU.Build.0 = Debug|x64 {D6856DBF-C959-4867-A8A8-343DA2D2715E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D6856DBF-C959-4867-A8A8-343DA2D2715E}.Debug|Any CPU.Build.0 = Debug|Any CPU {D6856DBF-C959-4867-A8A8-343DA2D2715E}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -130,6 +138,7 @@ Global {BA8A3E49-60D2-4BA2-B285-CB09FFDB6D32}.Release|Any CPU.ActiveCfg = Release|x64 {BA8A3E49-60D2-4BA2-B285-CB09FFDB6D32}.Release|x64.ActiveCfg = Release|x64 {BA8A3E49-60D2-4BA2-B285-CB09FFDB6D32}.Release|x64.Build.0 = Release|x64 + {BA8A3E49-60D2-4BA2-B285-CB09FFDB6D32}.Debug|Any CPU.Build.0 = Debug|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE