The Free Software Media System - Server Backend & API
Fix existing DisplayPreferences migration
crobiberoe765184afa04
diff --git a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs b/Jellyfin.Api/Controllers/DisplayPreferencesController.csindex e970524d3b..7c94880bce 100644--- a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs+++ b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs@@ -177,7 +177,7 @@ namespace Jellyfin.Api.Controllersforeach (var key in displayPreferences.CustomPrefs.Keys.Where(key => key.StartsWith("landing-", StringComparison.OrdinalIgnoreCase))){- if (Guid.TryParse(key.Substring("landing-".Length), out var preferenceId))+ if (Guid.TryParse(key.AsSpan().Slice("landing-".Length), out var preferenceId)){var itemPreferences = _displayPreferencesManager.GetItemDisplayPreferences(existingDisplayPreferences.UserId, preferenceId, existingDisplayPreferences.Client);itemPreferences.ViewType = Enum.Parse<ViewType>(displayPreferences.ViewType);diff --git a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.csindex 8992c281db..7b79184fc0 100644--- a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs+++ b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs@@ -105,6 +105,7 @@ namespace Jellyfin.Server.Migrations.Routinesvar chromecastVersion = dto.CustomPrefs.TryGetValue("chromecastVersion", out var version)? chromecastDict[version]: ChromecastVersion.Stable;+ dto.CustomPrefs.Remove("chromecastVersion");var displayPreferences = new DisplayPreferences(dtoUserId, result[2].ToString()){@@ -126,15 +127,24 @@ namespace Jellyfin.Server.Migrations.RoutinesTvHome = dto.CustomPrefs.TryGetValue("tvhome", out var home) ? home : string.Empty};+ dto.CustomPrefs.Remove("skipForwardLength");+ dto.CustomPrefs.Remove("skipBackLength");+ dto.CustomPrefs.Remove("enableNextVideoInfoOverlay");+ dto.CustomPrefs.Remove("dashboardtheme");+ dto.CustomPrefs.Remove("tvhome");+for (int i = 0; i < 7; i++){- dto.CustomPrefs.TryGetValue("homesection" + i, out var homeSection);+ var key = "homesection" + i;+ dto.CustomPrefs.TryGetValue(key, out var homeSection);displayPreferences.HomeSections.Add(new HomeSection{Order = i,Type = Enum.TryParse<HomeSectionType>(homeSection, true, out var type) ? type : defaults[i]});++ dto.CustomPrefs.Remove(key);}var defaultLibraryPrefs = new ItemDisplayPreferences(displayPreferences.UserId, Guid.Empty, displayPreferences.Client)@@ -167,9 +177,15 @@ namespace Jellyfin.Server.Migrations.RoutineslibraryDisplayPreferences.ViewType = viewType;}+ dto.CustomPrefs.Remove(key);dbContext.ItemDisplayPreferences.Add(libraryDisplayPreferences);}+ foreach (var (key, value) in dto.CustomPrefs)+ {+ dbContext.Add(new CustomItemDisplayPreferences(displayPreferences.UserId, displayPreferences.Client, key, value));+ }+dbContext.Add(displayPreferences);}