Delete the penumbrametatmp folder on migration.

This commit is contained in:
Ottermandias 2022-06-05 12:38:11 +02:00
parent 3b2876a6e4
commit b71552607e

View file

@ -63,6 +63,7 @@ public partial class Configuration
// The forced collection was removed due to general inheritance.
// Sort Order was moved to a separate file and may contain empty folders.
// Active collections in general were moved to their own file.
// Delete the penumbrametatmp folder if it exists.
private void Version1To2()
{
if( _config.Version != 1 )
@ -71,6 +72,7 @@ public partial class Configuration
}
// Ensure the right meta files are loaded.
DeleteMetaTmp();
Penumbra.CharacterUtility.LoadCharacterResources();
ResettleSortOrder();
ResettleCollectionSettings();
@ -78,6 +80,22 @@ public partial class Configuration
_config.Version = 2;
}
private void DeleteMetaTmp()
{
var path = Path.Combine( _config.ModDirectory, "penumbrametatmp" );
if( Directory.Exists( path ) )
{
try
{
Directory.Delete( path, true );
}
catch( Exception e )
{
PluginLog.Error( $"Could not delete the outdated penumbrametatmp folder:\n{e}" );
}
}
}
private void ResettleForcedCollection()
{
ForcedCollection = _data[ nameof( ForcedCollection ) ]?.ToObject< string >() ?? ForcedCollection;