mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-16 05:34:25 +01:00
Create permanent backup before migrating collections.
This commit is contained in:
parent
36fc251d5b
commit
2a5df2dfb0
3 changed files with 28 additions and 4 deletions
|
|
@ -136,7 +136,7 @@ public class Configuration : IPluginConfiguration, ISavable
|
||||||
/// <summary> Contains some default values or boundaries for config values. </summary>
|
/// <summary> Contains some default values or boundaries for config values. </summary>
|
||||||
public static class Constants
|
public static class Constants
|
||||||
{
|
{
|
||||||
public const int CurrentVersion = 8;
|
public const int CurrentVersion = 9;
|
||||||
public const float MaxAbsoluteSize = 600;
|
public const float MaxAbsoluteSize = 600;
|
||||||
public const int DefaultAbsoluteSize = 250;
|
public const int DefaultAbsoluteSize = 250;
|
||||||
public const float MinAbsoluteSize = 50;
|
public const float MinAbsoluteSize = 50;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@ namespace Penumbra.Services;
|
||||||
|
|
||||||
public class BackupService : IAsyncService
|
public class BackupService : IAsyncService
|
||||||
{
|
{
|
||||||
|
private readonly Logger _logger;
|
||||||
|
private readonly DirectoryInfo _configDirectory;
|
||||||
|
private readonly IReadOnlyList<FileInfo> _fileNames;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Task Awaiter { get; }
|
public Task Awaiter { get; }
|
||||||
|
|
||||||
|
|
@ -17,10 +21,16 @@ public class BackupService : IAsyncService
|
||||||
/// <summary> Start a backup process on the collected files. </summary>
|
/// <summary> Start a backup process on the collected files. </summary>
|
||||||
public BackupService(Logger logger, FilenameService fileNames)
|
public BackupService(Logger logger, FilenameService fileNames)
|
||||||
{
|
{
|
||||||
var files = PenumbraFiles(fileNames);
|
_logger = logger;
|
||||||
Awaiter = Task.Run(() => Backup.CreateAutomaticBackup(logger, new DirectoryInfo(fileNames.ConfigDirectory), files));
|
_fileNames = PenumbraFiles(fileNames);
|
||||||
|
_configDirectory = new DirectoryInfo(fileNames.ConfigDirectory);
|
||||||
|
Awaiter = Task.Run(() => Backup.CreateAutomaticBackup(logger, new DirectoryInfo(fileNames.ConfigDirectory), _fileNames));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Create a permanent backup with a given name for migrations. </summary>
|
||||||
|
public void CreateMigrationBackup(string name)
|
||||||
|
=> Backup.CreatePermanentBackup(_logger, _configDirectory, _fileNames, name);
|
||||||
|
|
||||||
/// <summary> Collect all relevant files for penumbra configuration. </summary>
|
/// <summary> Collect all relevant files for penumbra configuration. </summary>
|
||||||
private static IReadOnlyList<FileInfo> PenumbraFiles(FilenameService fileNames)
|
private static IReadOnlyList<FileInfo> PenumbraFiles(FilenameService fileNames)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Penumbra.Services;
|
||||||
/// Contains everything to migrate from older versions of the config to the current,
|
/// Contains everything to migrate from older versions of the config to the current,
|
||||||
/// including deprecated fields.
|
/// including deprecated fields.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ConfigMigrationService(SaveService saveService) : IService
|
public class ConfigMigrationService(SaveService saveService, BackupService backupService) : IService
|
||||||
{
|
{
|
||||||
private Configuration _config = null!;
|
private Configuration _config = null!;
|
||||||
private JObject _data = null!;
|
private JObject _data = null!;
|
||||||
|
|
@ -73,9 +73,23 @@ public class ConfigMigrationService(SaveService saveService) : IService
|
||||||
Version5To6();
|
Version5To6();
|
||||||
Version6To7();
|
Version6To7();
|
||||||
Version7To8();
|
Version7To8();
|
||||||
|
Version8To9();
|
||||||
AddColors(config, true);
|
AddColors(config, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Migrate to ephemeral config.
|
||||||
|
private void Version8To9()
|
||||||
|
{
|
||||||
|
if (_config.Version != 8)
|
||||||
|
return;
|
||||||
|
|
||||||
|
backupService.CreateMigrationBackup("pre_collection_identifiers");
|
||||||
|
_config.Version = 9;
|
||||||
|
_config.Ephemeral.Version = 9;
|
||||||
|
_config.Save();
|
||||||
|
_config.Ephemeral.Save();
|
||||||
|
}
|
||||||
|
|
||||||
// Migrate to ephemeral config.
|
// Migrate to ephemeral config.
|
||||||
private void Version7To8()
|
private void Version7To8()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue