Core - Simplify PluginInfo and PluginFeatureInfo

This commit is contained in:
Robert committed 2024-03-01 22:23:49 +01:00
1 parent baae4af153
commit ba3838489f
4 files changed
+114 -213

No files matched your search

@@ -2,6 +2,7 @@ using System;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Nodes;
using Serilog;
namespace Artemis.Storage.Migrations.Profile
{
@@ -11,6 +12,13 @@ namespace Artemis.Storage.Migrations.Profile
/// </summary>
internal class M0004NodeStorage : IProfileMigration
{
private readonly ILogger _logger;
public M0004NodeStorage(ILogger logger)
{
_logger = logger;
}
/// <inheritdoc />
public int Version => 4;
@@ -89,11 +97,11 @@ namespace Artemis.Storage.Migrations.Profile
continue;
JsonObject nodeObject = jsonNode.AsObject();
nodeObject["Storage"] = MigrateNodeStorageJson(nodeObject["Storage"]?.GetValue<string>());
nodeObject["Storage"] = MigrateNodeStorageJson(nodeObject["Storage"]?.GetValue<string>(), _logger);
}
}
internal static string? MigrateNodeStorageJson(string? json)
internal static string? MigrateNodeStorageJson(string? json, ILogger logger)
{
if (string.IsNullOrEmpty(json))
return json;
@@ -131,6 +139,7 @@ namespace Artemis.Storage.Migrations.Profile
}
catch (Exception e)
{
logger.Error(e, "Failed to migrate node storage JSON");
return json;
}
}
@@ -1,11 +1,18 @@
using System.Collections.Generic;
using Artemis.Storage.Migrations.Profile;
using LiteDB;
using Serilog;
namespace Artemis.Storage.Migrations.Storage;
public class M0026NodeStorage : IStorageMigration
{
private readonly ILogger _logger;
public M0026NodeStorage(ILogger logger)
{
_logger = logger;
}
public int UserVersion => 26;
public void Apply(LiteRepository repository)
@@ -106,7 +113,7 @@ public class M0026NodeStorage : IStorageMigration
foreach (BsonValue node in nodes)
{
// Migrate the storage of the node
node["Storage"] = M0004NodeStorage.MigrateNodeStorageJson(node.AsDocument["Storage"]?.AsString);
node["Storage"] = M0004NodeStorage.MigrateNodeStorageJson(node.AsDocument["Storage"]?.AsString, _logger);
}
}
}