aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2021-06-27 16:46:09 -0400
committerPatrick Barron <barronpm@gmail.com>2021-06-27 16:46:09 -0400
commit06d682c29679d904bc1b21aa493bb9ed29bda265 (patch)
tree2669aa4c4481aa3c70147b52c245824e3ea4b873
parentaf2e7aec2ecff589c91b8064b1dff2ff5afcf172 (diff)
parent5d1139ec62ff0c177e45574a6c3ce7ecf51aff57 (diff)
Merge remote-tracking branch 'origin/authenticationdb-efcore' into authenticationdb-efcore
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs2
-rw-r--r--Jellyfin.Server.Implementations/Devices/DeviceManager.cs1
-rw-r--r--Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs28
3 files changed, 28 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index ac730fa43..ea710013e 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)
{
diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
index b02ca4ef0..ef0d5db09 100644
--- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
+++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
@@ -170,6 +170,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)
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateAuthenticationDb.cs
index 6c9ad0338..21f153623 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<string>();
+ 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();
}