FIX: null Publications in tasks

This commit is contained in:
glax 2023-07-29 18:55:06 +02:00
parent 16238c590b
commit 42596752d3
2 changed files with 6 additions and 4 deletions

View File

@ -26,7 +26,8 @@ public static class Migrate
return; return;
string tasksJsonString = File.ReadAllText(settings.tasksFilePath); string tasksJsonString = File.ReadAllText(settings.tasksFilePath);
List<TrangaTask> tasks = JsonConvert.DeserializeObject<List<TrangaTask>>(tasksJsonString, new JsonSerializerSettings { Converters = { new TrangaTask.TrangaTaskJsonConverter() } })!; HashSet<TrangaTask> tasks = JsonConvert.DeserializeObject<HashSet<TrangaTask>>(tasksJsonString, new JsonSerializerSettings { Converters = { new TrangaTask.TrangaTaskJsonConverter() } })!;
tasks.RemoveAll(t => t.task == TrangaTask.Task.UpdateLibraries); tasks.RemoveWhere(t => t.task == TrangaTask.Task.UpdateLibraries);
File.WriteAllText(settings.tasksFilePath, JsonConvert.SerializeObject(tasks));
} }
} }

View File

@ -30,7 +30,8 @@ public struct Publication
private static readonly Regex LegalCharacters = new Regex(@"[A-Z]*[a-z]*[0-9]* *\.*-*,*'*\'*\)*\(*~*!*"); private static readonly Regex LegalCharacters = new Regex(@"[A-Z]*[a-z]*[0-9]* *\.*-*,*'*\'*\)*\(*~*!*");
public Publication(string sortName, List<string> authors, string? description, Dictionary<string,string> altTitles, string[] tags, string? posterUrl, string? coverFileNameInCache, Dictionary<string,string>? links, int? year, string? originalLanguage, string status, string publicationId, string? folderName = null, float ignoreChaptersBelow = 0) [JsonConstructor]
public Publication(string sortName, List<string> authors, string? description, Dictionary<string,string> altTitles, string[] tags, string? posterUrl, string? coverFileNameInCache, Dictionary<string,string>? links, int? year, string? originalLanguage, string status, string publicationId, string? folderName = null, float? ignoreChaptersBelow = 0)
{ {
this.sortName = sortName; this.sortName = sortName;
this.authors = authors; this.authors = authors;
@ -49,7 +50,7 @@ public struct Publication
this.folderName = this.folderName.Substring(0, this.folderName.Length - 1); this.folderName = this.folderName.Substring(0, this.folderName.Length - 1);
string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter)); string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter));
this.internalId = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{onlyLowerLetters}{this.year}")); this.internalId = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{onlyLowerLetters}{this.year}"));
this.ignoreChaptersBelow = ignoreChaptersBelow; this.ignoreChaptersBelow = ignoreChaptersBelow ?? 0f;
} }
public string CreatePublicationFolder(string downloadDirectory) public string CreatePublicationFolder(string downloadDirectory)