From 16cdb11212f4e7b2a278b710d7bc5c50ab237a5b Mon Sep 17 00:00:00 2001 From: Paolo Ambrosio Date: Fri, 30 Jun 2023 16:07:28 +0100 Subject: [PATCH] Fix empty directories cleanup --- src/Core/Mods/JsgmeFileInstaller.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Core/Mods/JsgmeFileInstaller.cs b/src/Core/Mods/JsgmeFileInstaller.cs index 4925ebe..5974b3e 100644 --- a/src/Core/Mods/JsgmeFileInstaller.cs +++ b/src/Core/Mods/JsgmeFileInstaller.cs @@ -102,7 +102,8 @@ public static void UninstallFiles(string dstPath, IEnumerable files, Act /// Function to decide if a file should be skipped public static void UninstallFiles(string dstPath, IEnumerable files, Action fileUninstalledCallback, ShouldSkipFile skip) { - foreach (var file in files) + var fileList = files.ToList(); // It must be enumerated twice + foreach (var file in fileList) { var path = Path.Combine(dstPath, file); // Some mods have duplicate entries, so files might have been removed already @@ -120,7 +121,7 @@ public static void UninstallFiles(string dstPath, IEnumerable files, Act RestoreFile(path); fileUninstalledCallback(file); } - DeleteEmptyDirectories(dstPath, files); + DeleteEmptyDirectories(dstPath, fileList); } private static void DeleteEmptyDirectories(string dstRootPath, IEnumerable filePaths) {