From cec4ad9b656f3582fbb9524d5d5724f8d929f0b4 Mon Sep 17 00:00:00 2001 From: JPVenson Date: Sun, 10 Nov 2024 18:36:46 +0000 Subject: [PATCH] Improved Logging --- Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs index e0cec95908..7393c2c863 100644 --- a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs +++ b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs @@ -279,11 +279,14 @@ public class MigrateLibraryDb : IMigrationRoutine } } - private static (UserData? Data, string? LegacyUserDataKey) GetUserData(ImmutableArray users, SqliteDataReader dto) + private (UserData? Data, string? LegacyUserDataKey) GetUserData(ImmutableArray users, SqliteDataReader dto) { var indexOfUser = dto.GetInt32(1); - if (users.Length < indexOfUser) + var user = users.ElementAtOrDefault(indexOfUser); + + 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); } @@ -292,7 +295,7 @@ public class MigrateLibraryDb : IMigrationRoutine return (new UserData() { ItemId = Guid.NewGuid(), - UserId = users.ElementAt(indexOfUser).Id, + UserId = user.Id, Rating = dto.IsDBNull(2) ? null : dto.GetDouble(2), Played = dto.GetBoolean(3), PlayCount = dto.GetInt32(4),