From fdc84836c9631250be95b6013267287308267673 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 27 Apr 2022 18:25:56 +0200 Subject: [PATCH] Fix some migration and deletion stuff. --- Penumbra/Mods/Manager/Mod.Manager.Options.cs | 2 ++ Penumbra/Mods/Mod.Meta.Migration.cs | 32 ++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Penumbra/Mods/Manager/Mod.Manager.Options.cs b/Penumbra/Mods/Manager/Mod.Manager.Options.cs index cdfa142b..98267ae7 100644 --- a/Penumbra/Mods/Manager/Mod.Manager.Options.cs +++ b/Penumbra/Mods/Manager/Mod.Manager.Options.cs @@ -55,6 +55,8 @@ public sealed partial class Mod return; } + group.DeleteFile( mod.BasePath ); + var _ = group switch { SingleModGroup s => s.Name = newName, diff --git a/Penumbra/Mods/Mod.Meta.Migration.cs b/Penumbra/Mods/Mod.Meta.Migration.cs index 6b2ae97b..59a67cab 100644 --- a/Penumbra/Mods/Mod.Meta.Migration.cs +++ b/Penumbra/Mods/Mod.Meta.Migration.cs @@ -6,7 +6,6 @@ using Dalamud.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Penumbra.GameData.ByteString; -using Penumbra.Util; namespace Penumbra.Mods; @@ -50,13 +49,42 @@ public sealed partial class Mod mod._default.FileSwapData.Add( gamePath, swapPath ); } - mod._default.IncorporateMetaChanges( mod.BasePath, false ); + mod._default.IncorporateMetaChanges( mod.BasePath, true ); foreach( var group in mod.Groups ) { IModGroup.SaveModGroup( group, mod.BasePath ); } + // Delete meta files. + foreach( var file in seenMetaFiles.Where( f => f.Exists ) ) + { + try + { + File.Delete( file.FullName ); + } + catch( Exception e ) + { + PluginLog.Warning( $"Could not delete meta file {file.FullName} during migration:\n{e}" ); + } + } + + // Delete old meta files. + var oldMetaFile = Path.Combine( mod.BasePath.FullName, "metadata_manipulations.json" ); + if( File.Exists( oldMetaFile ) ) + { + try + { + File.Delete( oldMetaFile ); + } + catch( Exception e ) + { + PluginLog.Warning( $"Could not delete old meta file {oldMetaFile} during migration:\n{e}" ); + } + } + + mod.FileVersion = 1; mod.SaveDefaultMod(); + mod.SaveMeta(); return true; }