Fix a problem when incorporating deduplicated meta files simultaneously over multiple options.

This commit is contained in:
Ottermandias 2023-01-02 17:20:56 +01:00
parent 1268344d04
commit 20e6baee0b
2 changed files with 23 additions and 5 deletions

View file

@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -81,10 +82,18 @@ public partial class Mod
private void IncorporateAllMetaChanges( bool delete ) private void IncorporateAllMetaChanges( bool delete )
{ {
var changes = false; var changes = false;
List< string > deleteList = new();
foreach( var subMod in AllSubMods.OfType< SubMod >() ) 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 ) if( changes )
{ {

View file

@ -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 .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. // 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 deleteList = new List< string >();
var oldSize = ManipulationData.Count; 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 ) foreach( var file in deleteList )
{ {
try try
@ -238,8 +249,6 @@ public partial class Mod
Penumbra.Log.Error( $"Could not delete incorporated meta file {file}:\n{e}" ); Penumbra.Log.Error( $"Could not delete incorporated meta file {file}:\n{e}" );
} }
} }
return oldSize < ManipulationData.Count;
} }
public void WriteTexToolsMeta( DirectoryInfo basePath, bool test = false ) public void WriteTexToolsMeta( DirectoryInfo basePath, bool test = false )