Fix missing config file breaking plugin load
This commit is contained in:
parent
b658956c4b
commit
f02aeffb26
@ -15,6 +15,8 @@ namespace Pal.Client.Configuration
|
||||
[Obsolete("for V1 import")]
|
||||
internal static readonly byte[] FixedV1Entropy = { 0x22, 0x4b, 0xe7, 0x21, 0x44, 0x83, 0x69, 0x55, 0x80, 0x38 };
|
||||
|
||||
public const string ConfigFileName = "palace-pal.config.json";
|
||||
|
||||
private static bool? _supportsDpapi = null;
|
||||
public static bool SupportsDpapi
|
||||
{
|
||||
|
@ -23,17 +23,25 @@ namespace Pal.Client.Configuration
|
||||
|
||||
public event EventHandler<IPalacePalConfiguration>? Saved;
|
||||
|
||||
public ConfigurationManager(ILogger<ConfigurationManager> logger, DalamudPluginInterface pluginInterface, IServiceProvider serviceProvider)
|
||||
public ConfigurationManager(ILogger<ConfigurationManager> logger, DalamudPluginInterface pluginInterface,
|
||||
IServiceProvider serviceProvider)
|
||||
{
|
||||
_logger = logger;
|
||||
_pluginInterface = pluginInterface;
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
private string ConfigPath => Path.Join(_pluginInterface.GetPluginConfigDirectory(), "palace-pal.config.json");
|
||||
private string ConfigPath =>
|
||||
Path.Join(_pluginInterface.GetPluginConfigDirectory(), ConfigurationData.ConfigFileName);
|
||||
|
||||
public IPalacePalConfiguration Load()
|
||||
{
|
||||
if (!File.Exists(ConfigPath))
|
||||
{
|
||||
_logger.LogInformation("No config file exists, creating one");
|
||||
Save(new ConfigurationV7(), false);
|
||||
}
|
||||
|
||||
return JsonSerializer.Deserialize<ConfigurationV7>(File.ReadAllText(ConfigPath, Encoding.UTF8)) ??
|
||||
new ConfigurationV7();
|
||||
}
|
||||
@ -61,7 +69,8 @@ namespace Pal.Client.Configuration
|
||||
ConfigurationV1 configurationV1 =
|
||||
NJson.JsonConvert.DeserializeObject<ConfigurationV1>(
|
||||
File.ReadAllText(_pluginInterface.ConfigFile.FullName)) ?? new ConfigurationV1();
|
||||
configurationV1.Migrate(_pluginInterface, _serviceProvider.GetRequiredService<ILogger<ConfigurationV1>>());
|
||||
configurationV1.Migrate(_pluginInterface,
|
||||
_serviceProvider.GetRequiredService<ILogger<ConfigurationV1>>());
|
||||
configurationV1.Save(_pluginInterface);
|
||||
|
||||
var v7 = MigrateToV7(configurationV1);
|
||||
|
@ -43,20 +43,21 @@ namespace Pal.Client
|
||||
|
||||
_logger.LogInformation("Starting async init");
|
||||
|
||||
await RemoveOldBackups();
|
||||
await CreateBackups();
|
||||
await CreateBackup();
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
await RunMigrations(cancellationToken);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
await RunCleanup();
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// v1 migration: config migration for import history, json migration for markers
|
||||
_serviceProvider.GetRequiredService<ConfigurationManager>().Migrate();
|
||||
await _serviceProvider.GetRequiredService<JsonMigration>().MigrateAsync(cancellationToken);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
await RunCleanup();
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
await RemoveOldBackups();
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// windows that have logic to open on startup
|
||||
@ -129,7 +130,7 @@ namespace Pal.Client
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CreateBackups()
|
||||
private async Task CreateBackup()
|
||||
{
|
||||
await using var scope = _serviceProvider.CreateAsyncScope();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user