diff options
| author | Cody Robibero <cody@robibe.ro> | 2022-05-02 07:41:13 -0600 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2022-05-20 18:30:57 -0400 |
| commit | abd3f411bd47c14d6c1b2585466208a902fd1c74 (patch) | |
| tree | 4deaabf5e838781a5f720fd1ec75f70ffc054c58 | |
| parent | 2b1a915eadbf26320f2c0baf988abc434102816d (diff) | |
Merge pull request #7693 from crobibero/auth-migrate
(cherry picked from commit 3229ba4918cb31913b47c99c5a817dae3366f020)
Signed-off-by: crobibero <cody@robibe.ro>
| -rw-r--r-- | Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs index afd7aee5d..ba0e33585 100644 --- a/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs +++ b/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs @@ -5,6 +5,7 @@ using Emby.Server.Implementations.Data; using Jellyfin.Data.Entities.Security; using Jellyfin.Server.Implementations; using MediaBrowser.Controller; +using MediaBrowser.Controller.Library; using Microsoft.Extensions.Logging; using SQLitePCL.pretty; @@ -20,6 +21,7 @@ namespace Jellyfin.Server.Migrations.Routines private readonly ILogger<MigrateAuthenticationDb> _logger; private readonly JellyfinDbProvider _dbProvider; private readonly IServerApplicationPaths _appPaths; + private readonly IUserManager _userManager; /// <summary> /// Initializes a new instance of the <see cref="MigrateAuthenticationDb"/> class. @@ -27,11 +29,17 @@ namespace Jellyfin.Server.Migrations.Routines /// <param name="logger">The logger.</param> /// <param name="dbProvider">The database provider.</param> /// <param name="appPaths">The server application paths.</param> - public MigrateAuthenticationDb(ILogger<MigrateAuthenticationDb> logger, JellyfinDbProvider dbProvider, IServerApplicationPaths appPaths) + /// <param name="userManager">The user manager.</param> + public MigrateAuthenticationDb( + ILogger<MigrateAuthenticationDb> logger, + JellyfinDbProvider dbProvider, + IServerApplicationPaths appPaths, + IUserManager userManager) { _logger = logger; _dbProvider = dbProvider; _appPaths = appPaths; + _userManager = userManager; } /// <inheritdoc /> @@ -74,6 +82,14 @@ namespace Jellyfin.Server.Migrations.Routines } else { + var userId = new Guid(row[6].ToString()); + var user = _userManager.GetUserById(userId); + if (user is null) + { + // User doesn't exist, don't bring over the device. + continue; + } + dbContext.Devices.Add(new Device( new Guid(row[6].ToString()), row[3].ToString(), |
