From dbfd30ec4c33bb014d987e3bcb2e7a73a5389c15 Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Thu, 24 Jun 2021 09:38:37 -0400 Subject: [PATCH 1/3] Migrate DeviceOptions --- .../Routines/MigrateAuthenticationDb.cs | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs index 6c9ad03389..21f153623e 100644 --- a/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs +++ b/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using Emby.Server.Implementations.Data; using Jellyfin.Data.Entities.Security; @@ -53,9 +54,9 @@ namespace Jellyfin.Server.Migrations.Routines { using var dbContext = _dbProvider.CreateContext(); - var queryResult = connection.Query("SELECT * FROM Tokens"); + var authenticatedDevices = connection.Query("SELECT * FROM Tokens"); - foreach (var row in queryResult) + foreach (var row in authenticatedDevices) { if (row[6].IsDbNull()) { @@ -83,6 +84,29 @@ namespace Jellyfin.Server.Migrations.Routines } } + var deviceOptions = connection.Query("SELECT * FROM Devices"); + var deviceIds = new HashSet(); + foreach (var row in deviceOptions) + { + if (row[2].IsDbNull()) + { + continue; + } + + var deviceId = row[2].ToString(); + if (deviceIds.Contains(deviceId)) + { + continue; + } + + deviceIds.Add(deviceId); + + dbContext.DeviceOptions.Add(new DeviceOptions(deviceId) + { + CustomName = row[1].IsDbNull() ? null : row[1].ToString() + }); + } + dbContext.SaveChanges(); } From befedaf6fc70456557de71b9d1d223f669e5c22b Mon Sep 17 00:00:00 2001 From: Patrick Barron <18354464+barronpm@users.noreply.github.com> Date: Fri, 25 Jun 2021 21:13:38 -0400 Subject: [PATCH 2/3] Update Emby.Server.Implementations/Session/SessionManager.cs Co-authored-by: Cody Robibero --- Emby.Server.Implementations/Session/SessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 40a346e95e..9dada44cba 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -293,7 +293,7 @@ namespace Emby.Server.Implementations.Session try { user.LastActivityDate = activityDate; - await _userManager.UpdateUserAsync(user); + await _userManager.UpdateUserAsync(user).ConfigureAwait(false); } catch (DbUpdateConcurrencyException e) { From 5d1139ec62ff0c177e45574a6c3ce7ecf51aff57 Mon Sep 17 00:00:00 2001 From: Patrick Barron <18354464+barronpm@users.noreply.github.com> Date: Sat, 26 Jun 2021 15:17:57 -0400 Subject: [PATCH 3/3] Update Jellyfin.Server.Implementations/Devices/DeviceManager.cs Co-authored-by: Cody Robibero --- Jellyfin.Server.Implementations/Devices/DeviceManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs index 484a53428c..86706cac97 100644 --- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs +++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs @@ -168,6 +168,7 @@ namespace Jellyfin.Server.Implementations.Devices { await using var dbContext = _dbProvider.CreateContext(); var sessions = dbContext.Devices + .Include(d => d.User) .AsQueryable() .OrderBy(d => d.DeviceId) .ThenByDescending(d => d.DateLastActivity)