From 356a22d72e021a21f307a1982cdc2bfa5e14c064 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 22 Jul 2025 17:59:25 +0200 Subject: [PATCH] Fix Merge of Manga --- API/Schema/MangaContext/MangaConnectorId.cs | 3 ++- API/Tranga.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/API/Schema/MangaContext/MangaConnectorId.cs b/API/Schema/MangaContext/MangaConnectorId.cs index b5de903..22797d0 100644 --- a/API/Schema/MangaContext/MangaConnectorId.cs +++ b/API/Schema/MangaContext/MangaConnectorId.cs @@ -8,7 +8,7 @@ namespace API.Schema.MangaContext; [PrimaryKey("Key")] public class MangaConnectorId : Identifiable where T : Identifiable { - [StringLength(64)] [Required] public string ObjId { get; private set; } = null!; + [StringLength(64)] [Required] public string ObjId { get; private set; } [JsonIgnore] public T Obj = null!; [StringLength(32)] [Required] public string MangaConnectorName { get; private set; } @@ -21,6 +21,7 @@ public class MangaConnectorId : Identifiable where T : Identifiable : base(TokenGen.CreateToken(typeof(MangaConnectorId), mangaConnector.Name, idOnConnectorSite)) { this.Obj = obj; + this.ObjId = obj.Key; this.MangaConnectorName = mangaConnector.Name; this.IdOnConnectorSite = idOnConnectorSite; this.WebsiteUrl = websiteUrl; diff --git a/API/Tranga.cs b/API/Tranga.cs index 829c5d5..ede9bf1 100644 --- a/API/Tranga.cs +++ b/API/Tranga.cs @@ -9,6 +9,7 @@ using API.Workers; using API.Workers.MaintenanceWorkers; using log4net; using log4net.Config; +using Microsoft.EntityFrameworkCore.ChangeTracking; namespace API; @@ -165,6 +166,10 @@ public static class Tranga MangaConnectorId mcId = context.MangaConnectorToManga.Find(addMcId.Key) ?? addMcId; mcId.Obj = manga; + foreach (CollectionEntry collectionEntry in context.Entry(manga).Collections) + collectionEntry.Load(); + context.Entry(manga).Navigation(nameof(Manga.Library)).Load(); + IEnumerable mergedTags = manga.MangaTags.Select(mt => { MangaTag? inDb = context.Tags.Find(mt.Tag);