mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Make mods added via API migrate models if enabled.
This commit is contained in:
parent
8ee326853d
commit
6e351aa68b
2 changed files with 13 additions and 1 deletions
|
|
@ -15,15 +15,17 @@ public class ModsApi : IPenumbraApiMods, IApiService, IDisposable
|
|||
private readonly ModImportManager _modImportManager;
|
||||
private readonly Configuration _config;
|
||||
private readonly ModFileSystem _modFileSystem;
|
||||
private readonly MigrationManager _migrationManager;
|
||||
|
||||
public ModsApi(ModManager modManager, ModImportManager modImportManager, Configuration config, ModFileSystem modFileSystem,
|
||||
CommunicatorService communicator)
|
||||
CommunicatorService communicator, MigrationManager migrationManager)
|
||||
{
|
||||
_modManager = modManager;
|
||||
_modImportManager = modImportManager;
|
||||
_config = config;
|
||||
_modFileSystem = modFileSystem;
|
||||
_communicator = communicator;
|
||||
_migrationManager = migrationManager;
|
||||
_communicator.ModPathChanged.Subscribe(OnModPathChanged, ModPathChanged.Priority.ApiMods);
|
||||
}
|
||||
|
||||
|
|
@ -81,9 +83,16 @@ public class ModsApi : IPenumbraApiMods, IApiService, IDisposable
|
|||
return ApiHelpers.Return(PenumbraApiEc.InvalidArgument, args);
|
||||
|
||||
_modManager.AddMod(dir);
|
||||
if (_config.MigrateImportedModelsToV6)
|
||||
{
|
||||
_migrationManager.MigrateMdlDirectory(dir.FullName, false);
|
||||
_migrationManager.Await();
|
||||
}
|
||||
|
||||
if (_config.UseFileSystemCompression)
|
||||
new FileCompactor(Penumbra.Log).StartMassCompact(dir.EnumerateFiles("*.*", SearchOption.AllDirectories),
|
||||
CompressionAlgorithm.Xpress8K);
|
||||
|
||||
return ApiHelpers.Return(PenumbraApiEc.Success, args);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ public class MigrationManager(Configuration config) : IService
|
|||
public void CleanMtrlBackups(string path)
|
||||
=> CleanBackups(path, "*.mtrl.bak", "material", MtrlCleanup, TaskType.MtrlCleanup);
|
||||
|
||||
public void Await()
|
||||
=> _currentTask?.Wait();
|
||||
|
||||
private void CleanBackups(string path, string extension, string fileType, MigrationData data, TaskType type)
|
||||
{
|
||||
if (IsRunning)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue