From 79c0a7d7f0ad27d9343891a8051f1654ba7a7376 Mon Sep 17 00:00:00 2001 From: gnattu Date: Sat, 29 Jun 2024 14:07:31 +0800 Subject: [PATCH] Don't cache user in DeviceManager, query from user cache instead Signed-off-by: gnattu --- Jellyfin.Server.Implementations/Devices/DeviceManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs index be2c02a6aa..fd88e86557 100644 --- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs +++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs @@ -44,7 +44,6 @@ namespace Jellyfin.Server.Implementations.Devices using var dbContext = _dbProvider.CreateDbContext(); foreach (var device in dbContext.Devices - .Include(d => d.User) .OrderBy(d => d.Id) .AsEnumerable()) { @@ -101,7 +100,6 @@ namespace Jellyfin.Server.Implementations.Devices await dbContext.SaveChangesAsync().ConfigureAwait(false); var newDevice = await dbContext.Devices - .Include(d => d.User) .FirstOrDefaultAsync(d => d.Id == device.Id) .ConfigureAwait(false); _devices.TryAdd(device.Id, newDevice!); @@ -239,6 +237,11 @@ namespace Jellyfin.Server.Implementations.Devices private DeviceInfo ToDeviceInfo(Device authInfo, DeviceOptions? options = null) { var caps = GetCapabilities(authInfo.DeviceId); + var user = _userManager.GetUserById(authInfo.UserId); + if (user is null) + { + throw new ResourceNotFoundException(); + } return new DeviceInfo { @@ -246,7 +249,7 @@ namespace Jellyfin.Server.Implementations.Devices AppVersion = authInfo.AppVersion, Id = authInfo.DeviceId, LastUserId = authInfo.UserId, - LastUserName = authInfo.User.Username, + LastUserName = user.Username, Name = authInfo.DeviceName, DateLastActivity = authInfo.DateLastActivity, IconUrl = caps.IconUrl,