mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-14 20:54:16 +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 ModImportManager _modImportManager;
|
||||||
private readonly Configuration _config;
|
private readonly Configuration _config;
|
||||||
private readonly ModFileSystem _modFileSystem;
|
private readonly ModFileSystem _modFileSystem;
|
||||||
|
private readonly MigrationManager _migrationManager;
|
||||||
|
|
||||||
public ModsApi(ModManager modManager, ModImportManager modImportManager, Configuration config, ModFileSystem modFileSystem,
|
public ModsApi(ModManager modManager, ModImportManager modImportManager, Configuration config, ModFileSystem modFileSystem,
|
||||||
CommunicatorService communicator)
|
CommunicatorService communicator, MigrationManager migrationManager)
|
||||||
{
|
{
|
||||||
_modManager = modManager;
|
_modManager = modManager;
|
||||||
_modImportManager = modImportManager;
|
_modImportManager = modImportManager;
|
||||||
_config = config;
|
_config = config;
|
||||||
_modFileSystem = modFileSystem;
|
_modFileSystem = modFileSystem;
|
||||||
_communicator = communicator;
|
_communicator = communicator;
|
||||||
|
_migrationManager = migrationManager;
|
||||||
_communicator.ModPathChanged.Subscribe(OnModPathChanged, ModPathChanged.Priority.ApiMods);
|
_communicator.ModPathChanged.Subscribe(OnModPathChanged, ModPathChanged.Priority.ApiMods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,9 +83,16 @@ public class ModsApi : IPenumbraApiMods, IApiService, IDisposable
|
||||||
return ApiHelpers.Return(PenumbraApiEc.InvalidArgument, args);
|
return ApiHelpers.Return(PenumbraApiEc.InvalidArgument, args);
|
||||||
|
|
||||||
_modManager.AddMod(dir);
|
_modManager.AddMod(dir);
|
||||||
|
if (_config.MigrateImportedModelsToV6)
|
||||||
|
{
|
||||||
|
_migrationManager.MigrateMdlDirectory(dir.FullName, false);
|
||||||
|
_migrationManager.Await();
|
||||||
|
}
|
||||||
|
|
||||||
if (_config.UseFileSystemCompression)
|
if (_config.UseFileSystemCompression)
|
||||||
new FileCompactor(Penumbra.Log).StartMassCompact(dir.EnumerateFiles("*.*", SearchOption.AllDirectories),
|
new FileCompactor(Penumbra.Log).StartMassCompact(dir.EnumerateFiles("*.*", SearchOption.AllDirectories),
|
||||||
CompressionAlgorithm.Xpress8K);
|
CompressionAlgorithm.Xpress8K);
|
||||||
|
|
||||||
return ApiHelpers.Return(PenumbraApiEc.Success, args);
|
return ApiHelpers.Return(PenumbraApiEc.Success, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,9 @@ public class MigrationManager(Configuration config) : IService
|
||||||
public void CleanMtrlBackups(string path)
|
public void CleanMtrlBackups(string path)
|
||||||
=> CleanBackups(path, "*.mtrl.bak", "material", MtrlCleanup, TaskType.MtrlCleanup);
|
=> 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)
|
private void CleanBackups(string path, string extension, string fileType, MigrationData data, TaskType type)
|
||||||
{
|
{
|
||||||
if (IsRunning)
|
if (IsRunning)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue