2023-07-30 17:25:04 +02:00
|
|
|
|
using Newtonsoft.Json;
|
2023-07-30 16:26:29 +02:00
|
|
|
|
using Tranga.TrangaTasks;
|
2023-07-20 18:13:22 +02:00
|
|
|
|
|
|
|
|
|
namespace Tranga;
|
|
|
|
|
|
|
|
|
|
public static class Migrate
|
|
|
|
|
{
|
|
|
|
|
private static readonly ushort CurrentVersion = 16;
|
|
|
|
|
public static void Files(TrangaSettings settings)
|
|
|
|
|
{
|
|
|
|
|
settings.version ??= 15;
|
|
|
|
|
switch (settings.version)
|
|
|
|
|
{
|
|
|
|
|
case 15:
|
|
|
|
|
RemoveUpdateLibraryTask(settings);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
settings.version = CurrentVersion;
|
|
|
|
|
settings.ExportSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void RemoveUpdateLibraryTask(TrangaSettings settings)
|
|
|
|
|
{
|
2023-07-21 00:32:18 +02:00
|
|
|
|
if (!File.Exists(settings.tasksFilePath))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string tasksJsonString = File.ReadAllText(settings.tasksFilePath);
|
2023-07-29 18:55:06 +02:00
|
|
|
|
HashSet<TrangaTask> tasks = JsonConvert.DeserializeObject<HashSet<TrangaTask>>(tasksJsonString, new JsonSerializerSettings { Converters = { new TrangaTask.TrangaTaskJsonConverter() } })!;
|
|
|
|
|
tasks.RemoveWhere(t => t.task == TrangaTask.Task.UpdateLibraries);
|
|
|
|
|
File.WriteAllText(settings.tasksFilePath, JsonConvert.SerializeObject(tasks));
|
2023-07-20 18:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
}
|