From 20e6baee0b8a38340f342b4efb5008bc7ddf9d22 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 2 Jan 2023 17:20:56 +0100 Subject: [PATCH] Fix a problem when incorporating deduplicated meta files simultaneously over multiple options. --- Penumbra/Mods/Mod.BasePath.cs | 13 +++++++++++-- Penumbra/Mods/Subclasses/Mod.Files.SubMod.cs | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Penumbra/Mods/Mod.BasePath.cs b/Penumbra/Mods/Mod.BasePath.cs index 851ed943..3a849a26 100644 --- a/Penumbra/Mods/Mod.BasePath.cs +++ b/Penumbra/Mods/Mod.BasePath.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.IO; using System.Linq; @@ -80,12 +81,20 @@ public partial class Mod // Deletes the source files if delete is true. private void IncorporateAllMetaChanges( bool delete ) { - var changes = false; + var changes = false; + List< string > deleteList = new(); foreach( var subMod in AllSubMods.OfType< SubMod >() ) { - changes |= subMod.IncorporateMetaChanges( ModPath, delete ); + var (localChanges, localDeleteList) = subMod.IncorporateMetaChanges( ModPath, false ); + changes |= localChanges; + if( delete ) + { + deleteList.AddRange( localDeleteList ); + } } + SubMod.DeleteDeleteList( deleteList, delete ); + if( changes ) { SaveAllGroups(); diff --git a/Penumbra/Mods/Subclasses/Mod.Files.SubMod.cs b/Penumbra/Mods/Subclasses/Mod.Files.SubMod.cs index a7b4981f..80c35d0f 100644 --- a/Penumbra/Mods/Subclasses/Mod.Files.SubMod.cs +++ b/Penumbra/Mods/Subclasses/Mod.Files.SubMod.cs @@ -182,7 +182,7 @@ public partial class Mod // If .meta or .rgsp files are encountered, parse them and incorporate their meta changes into the mod. // If delete is true, the files are deleted afterwards. - public bool IncorporateMetaChanges( DirectoryInfo basePath, bool delete ) + public (bool Changes, List< string > DeleteList) IncorporateMetaChanges( DirectoryInfo basePath, bool delete ) { var deleteList = new List< string >(); var oldSize = ManipulationData.Count; @@ -227,6 +227,17 @@ public partial class Mod } } + DeleteDeleteList( deleteList, delete ); + return ( oldSize < ManipulationData.Count, deleteList ); + } + + internal static void DeleteDeleteList( IEnumerable< string > deleteList, bool delete ) + { + if( !delete ) + { + return; + } + foreach( var file in deleteList ) { try @@ -238,8 +249,6 @@ public partial class Mod Penumbra.Log.Error( $"Could not delete incorporated meta file {file}:\n{e}" ); } } - - return oldSize < ManipulationData.Count; } public void WriteTexToolsMeta( DirectoryInfo basePath, bool test = false )