aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-12-03 15:00:26 -0700
committercrobibero <cody@robibe.ro>2020-12-03 15:00:26 -0700
commite765184afa04b4f901f97406bada0cf94bc81605 (patch)
treecc8a9352e9127f7a2ce31d6686b61b4cbda995a2
parent685c96646849ddfebd47017345595a239a83b58d (diff)
Fix existing DisplayPreferences migration
-rw-r--r--Jellyfin.Api/Controllers/DisplayPreferencesController.cs2
-rw-r--r--Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs18
2 files changed, 18 insertions, 2 deletions
diff --git a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
index e970524d3..7c94880bc 100644
--- a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
+++ b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
@@ -177,7 +177,7 @@ namespace Jellyfin.Api.Controllers
foreach (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.cs
index 8992c281d..7b79184fc 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
@@ -105,6 +105,7 @@ namespace Jellyfin.Server.Migrations.Routines
var 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.Routines
TvHome = 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.Routines
libraryDisplayPreferences.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);
}