diff --git a/Penumbra/Mods/CollectionManager.cs b/Penumbra/Mods/CollectionManager.cs index 9e617746..f3ce8cd5 100644 --- a/Penumbra/Mods/CollectionManager.cs +++ b/Penumbra/Mods/CollectionManager.cs @@ -54,6 +54,24 @@ namespace Penumbra.Mods public bool ResetActiveCollection() => SetActiveCollection( DefaultCollection, string.Empty ); + public void CreateNecessaryCaches() + { + if( !_manager.TempWritable ) + { + PluginLog.Error( "No temporary directory available." ); + return; + } + + if( DefaultCollection.Cache == null ) + DefaultCollection.CreateCache( _manager.TempPath, _manager.StructuredMods.AllMods( _manager.Config.SortFoldersFirst )); + + if( ForcedCollection.Cache == null ) + ForcedCollection.CreateCache( _manager.TempPath, _manager.StructuredMods.AllMods( _manager.Config.SortFoldersFirst ) ); + + foreach (var (_, collection) in CharacterCollection.Where( kvp => kvp.Value.Cache == null )) + collection.CreateCache( _manager.TempPath, _manager.StructuredMods.AllMods( _manager.Config.SortFoldersFirst ) ); + } + public void RecreateCaches() { if( !_manager.TempWritable ) @@ -66,6 +84,8 @@ namespace Penumbra.Mods { collection.CreateCache( _manager.TempPath, _manager.StructuredMods.AllMods( _manager.Config.SortFoldersFirst ) ); } + + CreateNecessaryCaches(); } public void RemoveModFromCaches( DirectoryInfo modDir ) diff --git a/Penumbra/Mods/ModManager.cs b/Penumbra/Mods/ModManager.cs index 846d06fb..03846e9c 100644 --- a/Penumbra/Mods/ModManager.cs +++ b/Penumbra/Mods/ModManager.cs @@ -129,6 +129,8 @@ namespace Penumbra.Mods TempWritable = false; } } + + Collections?.RecreateCaches(); } } diff --git a/Penumbra/UI/MenuTabs/TabDebug.cs b/Penumbra/UI/MenuTabs/TabDebug.cs index 98a920de..a57697d0 100644 --- a/Penumbra/UI/MenuTabs/TabDebug.cs +++ b/Penumbra/UI/MenuTabs/TabDebug.cs @@ -145,15 +145,22 @@ namespace Penumbra.UI var manager = Service< ModManager >.Get(); PrintValue( "Active Collection", manager.Collections.ActiveCollection.Name ); - PrintValue( "Mod Manager BasePath", manager.BasePath.Name ); - PrintValue( "Mod Manager BasePath-Full", manager.BasePath.FullName ); + PrintValue( " has Cache", (manager.Collections.ActiveCollection.Cache != null).ToString() ); + PrintValue( "Current Collection", manager.Collections.CurrentCollection.Name ); + PrintValue( " has Cache", ( manager.Collections.CurrentCollection.Cache != null ).ToString() ); + PrintValue( "Default Collection", manager.Collections.DefaultCollection.Name ); + PrintValue( " has Cache", ( manager.Collections.DefaultCollection.Cache != null ).ToString() ); + PrintValue( "Forced Collection", manager.Collections.ForcedCollection.Name ); + PrintValue( " has Cache", ( manager.Collections.ForcedCollection.Cache != null ).ToString() ); + PrintValue( "Mod Manager BasePath", manager.BasePath?.Name ?? "NULL" ); + PrintValue( "Mod Manager BasePath-Full", manager.BasePath?.FullName ?? "NULL" ); PrintValue( "Mod Manager BasePath IsRooted", Path.IsPathRooted( Penumbra.Config.ModDirectory ).ToString() ); - PrintValue( "Mod Manager BasePath Exists", Directory.Exists( manager.BasePath.FullName ).ToString() ); + PrintValue( "Mod Manager BasePath Exists", manager.BasePath != null ? Directory.Exists( manager.BasePath.FullName ).ToString() : false.ToString() ); PrintValue( "Mod Manager Valid", manager.Valid.ToString() ); - PrintValue( "Mod Manager Temp Path", manager.TempPath.FullName ); + PrintValue( "Mod Manager Temp Path", manager.TempPath?.FullName ?? "NULL" ); PrintValue( "Mod Manager Temp Path IsRooted", ( !Penumbra.Config.TempDirectory.Any() || Path.IsPathRooted( Penumbra.Config.TempDirectory ) ).ToString() ); - PrintValue( "Mod Manager Temp Path Exists", Directory.Exists( manager.TempPath.FullName ).ToString() ); + PrintValue( "Mod Manager Temp Path Exists", manager.TempPath != null ? Directory.Exists( manager.TempPath.FullName ).ToString() : false.ToString() ); PrintValue( "Mod Manager Temp Path IsWritable", manager.TempWritable.ToString() ); }