diff options
| author | JPVenson <github@jpb.email> | 2024-11-11 17:39:50 +0000 |
|---|---|---|
| committer | JPVenson <github@jpb.email> | 2024-11-11 17:39:50 +0000 |
| commit | 508b27f15643dc04d0ca1dda92a3b18bdeb43a5a (patch) | |
| tree | e45283c63b0bd16d3e1cc8eed9c3e765a995fbf7 /Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs | |
| parent | bdab5e549eb158a9a58161e73cd0ef988ae37599 (diff) | |
Fixed Duplicate returns on grouping
Fixed UserDataKey not stored
Diffstat (limited to 'Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs')
| -rw-r--r-- | Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs index 571ac95eb..a440bc6d6 100644 --- a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs +++ b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs @@ -107,20 +107,20 @@ public class MigrateLibraryDb : IMigrationRoutine foreach (var entity in queryResult) { var userData = GetUserData(users, entity); - if (userData.Data is null) + if (userData is null) { _logger.LogError("Was not able to migrate user data with key {0}", entity.GetString(0)); continue; } - if (!legacyBaseItemWithUserKeys.TryGetValue(userData.LegacyUserDataKey!, out var refItem)) + if (!legacyBaseItemWithUserKeys.TryGetValue(userData.CustomDataKey!, out var refItem)) { _logger.LogError("Was not able to migrate user data with key {0} because it does not reference a valid BaseItem.", entity.GetString(0)); continue; } - userData.Data.ItemId = refItem.Id; - dbContext.UserData.Add(userData.Data); + userData.ItemId = refItem.Id; + dbContext.UserData.Add(userData); } _logger.LogInformation("Try saving {0} UserData entries.", dbContext.UserData.Local.Count); @@ -289,7 +289,7 @@ public class MigrateLibraryDb : IMigrationRoutine } } - private (UserData? Data, string? LegacyUserDataKey) GetUserData(ImmutableArray<User> users, SqliteDataReader dto) + private UserData? GetUserData(ImmutableArray<User> users, SqliteDataReader dto) { var indexOfUser = dto.GetInt32(1); var user = users.ElementAtOrDefault(indexOfUser - 1); @@ -297,14 +297,15 @@ public class MigrateLibraryDb : IMigrationRoutine if (user is null) { _logger.LogError("Tried to find user with index '{Idx}' but there are only '{MaxIdx}' users.", indexOfUser, users.Length); - return (null, null); + return null; } var oldKey = dto.GetString(0); - return (new UserData() + return new UserData() { ItemId = Guid.NewGuid(), + CustomDataKey = oldKey, UserId = user.Id, Rating = dto.IsDBNull(2) ? null : dto.GetDouble(2), Played = dto.GetBoolean(3), @@ -317,7 +318,7 @@ public class MigrateLibraryDb : IMigrationRoutine Likes = null, User = null!, Item = null! - }, oldKey); + }; } private AncestorId GetAncestorId(SqliteDataReader reader) |
