diff options
| author | JPVenson <github@jpb.email> | 2025-06-23 17:36:49 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-23 08:36:49 -0600 |
| commit | ba0eb8737140acec000d36aadd9018b86f319d1f (patch) | |
| tree | 7199909706dddf35e428e2a4f27652607c930991 /Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs | |
| parent | d561cef81ffa60802276e3be119e09c1c21c635e (diff) | |
Add migration to migrate disconnected UserData too (#14339)
Diffstat (limited to 'Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs')
| -rw-r--r-- | Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs index 7bb379eb6..e25c52786 100644 --- a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs +++ b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs @@ -183,12 +183,12 @@ internal class MigrateLibraryDb : IDatabaseMigrationRoutine using (new TrackedMigrationStep("Loading UserData", _logger)) { - var users = operation.JellyfinDbContext.Users.AsNoTracking().ToImmutableArray(); + var users = operation.JellyfinDbContext.Users.AsNoTracking().ToArray(); var userIdBlacklist = new HashSet<int>(); foreach (var entity in queryResult) { - var userData = GetUserData(users, entity, userIdBlacklist); + var userData = GetUserData(users, entity, userIdBlacklist, _logger); if (userData is null) { var userDataId = entity.GetString(0); @@ -212,8 +212,6 @@ internal class MigrateLibraryDb : IDatabaseMigrationRoutine userData.ItemId = refItem.Id; operation.JellyfinDbContext.UserData.Add(userData); } - - users.Clear(); } legacyBaseItemWithUserKeys.Clear(); @@ -404,7 +402,7 @@ internal class MigrateLibraryDb : IDatabaseMigrationRoutine return new DatabaseMigrationStep(dbContext, operationName, _logger); } - private UserData? GetUserData(ImmutableArray<User> users, SqliteDataReader dto, HashSet<int> userIdBlacklist) + internal static UserData? GetUserData(User[] users, SqliteDataReader dto, HashSet<int> userIdBlacklist, ILogger logger) { var internalUserId = dto.GetInt32(1); if (userIdBlacklist.Contains(internalUserId)) @@ -415,9 +413,9 @@ internal class MigrateLibraryDb : IDatabaseMigrationRoutine var user = users.FirstOrDefault(e => e.InternalId == internalUserId); if (user is null) { - _logger.LogError("Tried to find user with index '{Idx}' but was not found, skipping user data import.", internalUserId); userIdBlacklist.Add(internalUserId); + logger.LogError("Tried to find user with index '{Idx}' but there are only '{MaxIdx}' users.", internalUserId, users.Length); return null; } |
