From 77eec0f69690891a03b9045c27663207e215bca4 Mon Sep 17 00:00:00 2001 From: glax Date: Fri, 21 Jul 2023 00:32:18 +0200 Subject: [PATCH] Fix wrong deserialization --- Tranga/Migrate.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Tranga/Migrate.cs b/Tranga/Migrate.cs index 9eceeae..9ab7eee 100644 --- a/Tranga/Migrate.cs +++ b/Tranga/Migrate.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using Logging; +using Newtonsoft.Json; namespace Tranga; @@ -21,7 +22,11 @@ public static class Migrate private static void RemoveUpdateLibraryTask(TrangaSettings settings) { - List tasks = JsonConvert.DeserializeObject>(settings.tasksFilePath)!; + if (!File.Exists(settings.tasksFilePath)) + return; + + string tasksJsonString = File.ReadAllText(settings.tasksFilePath); + List tasks = JsonConvert.DeserializeObject>(tasksJsonString, new JsonSerializerSettings { Converters = { new TrangaTask.TrangaTaskJsonConverter() } })!; tasks.RemoveAll(t => t.task == TrangaTask.Task.UpdateLibraries); } } \ No newline at end of file