Merge pull request #4699 from crobibero/display_prefs_index

Fix CustomItemDisplayPreferences unique key collision in the migration
This commit is contained in:
Bond-009 2020-12-11 22:29:07 +01:00 committed by GitHub
commit b3caa51173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,6 +81,7 @@ namespace Jellyfin.Server.Migrations.Routines
{ "unstable", ChromecastVersion.Unstable }
};
var customDisplayPrefs = new HashSet<string>();
var dbFilePath = Path.Combine(_paths.DataPath, DbFilename);
using (var connection = SQLite3.Open(dbFilePath, ConnectionFlags.ReadOnly, null))
{
@ -184,8 +185,14 @@ namespace Jellyfin.Server.Migrations.Routines
}
foreach (var (key, value) in dto.CustomPrefs)
{
// Custom display preferences can have a key collision.
var indexKey = $"{displayPreferences.UserId}|{itemId}|{displayPreferences.Client}|{key}";
if (!customDisplayPrefs.Contains(indexKey))
{
dbContext.Add(new CustomItemDisplayPreferences(displayPreferences.UserId, itemId, displayPreferences.Client, key, value));
customDisplayPrefs.Add(indexKey);
}
}
dbContext.Add(displayPreferences);