From f397fc5b98468a370fb51696df608dfbb2f14213 Mon Sep 17 00:00:00 2001 From: JPVenson Date: Thu, 10 Oct 2024 20:03:15 +0000 Subject: [PATCH] Fixed CustomType serialisation --- .../Item/BaseItemRepository.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs index 5708391a50..208bb41987 100644 --- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs +++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs @@ -28,6 +28,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; +using Microsoft.AspNetCore.Http.Json; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using BaseItemDto = MediaBrowser.Controller.Entities.BaseItem; @@ -1485,12 +1486,18 @@ public sealed class BaseItemRepository( /// The dto to map. public BaseItemEntity Map(BaseItemDto dto) { + var dtoType = dto.GetType(); var entity = new BaseItemEntity() { - Type = dto.GetType().ToString(), + Type = dtoType.ToString(), Id = dto.Id }; + if (TypeRequiresDeserialization(dtoType)) + { + entity.Data = JsonSerializer.Serialize(dto, dtoType, JsonDefaults.Options); + } + entity.ParentId = !dto.ParentId.IsEmpty() ? dto.ParentId : null; entity.Path = GetPathToSave(dto.Path); entity.EndDate = dto.EndDate.GetValueOrDefault();