aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2021-06-27 16:42:26 -0400
committerPatrick Barron <barronpm@gmail.com>2021-06-27 16:42:26 -0400
commitbbac9ff67e60d243dbd05be60abfcf13c295cd84 (patch)
treefdf34a0f712e3feb97b014eb51a90172c837e88d
parentd3e02e918d5586b0b8c74f1b79a13b76a978defd (diff)
GetDeviceOptions always returns an instance of DeviceOptions
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs2
-rw-r--r--Jellyfin.Api/Controllers/DevicesController.cs6
-rw-r--r--Jellyfin.Server.Implementations/Devices/DeviceManager.cs6
3 files changed, 5 insertions, 9 deletions
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index 40a346e95..ac730fa43 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -535,7 +535,7 @@ namespace Emby.Server.Implementations.Session
}
var deviceOptions = await _deviceManager.GetDeviceOptions(deviceId).ConfigureAwait(false);
- if (string.IsNullOrEmpty(deviceOptions?.CustomName))
+ if (string.IsNullOrEmpty(deviceOptions.CustomName))
{
sessionInfo.DeviceName = deviceName;
}
diff --git a/Jellyfin.Api/Controllers/DevicesController.cs b/Jellyfin.Api/Controllers/DevicesController.cs
index d4c2dbba0..26b9a854d 100644
--- a/Jellyfin.Api/Controllers/DevicesController.cs
+++ b/Jellyfin.Api/Controllers/DevicesController.cs
@@ -107,12 +107,6 @@ namespace Jellyfin.Api.Controllers
[FromQuery, Required] string id,
[FromBody, Required] DeviceOptions deviceOptions)
{
- var existingDeviceOptions = await _deviceManager.GetDeviceOptions(id).ConfigureAwait(false);
- if (existingDeviceOptions == null)
- {
- return NotFound();
- }
-
await _deviceManager.UpdateDeviceOptions(id, deviceOptions).ConfigureAwait(false);
return NoContent();
}
diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
index 484a53428..b02ca4ef0 100644
--- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
+++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
@@ -74,13 +74,15 @@ namespace Jellyfin.Server.Implementations.Devices
}
/// <inheritdoc />
- public async Task<DeviceOptions?> GetDeviceOptions(string deviceId)
+ public async Task<DeviceOptions> GetDeviceOptions(string deviceId)
{
await using var dbContext = _dbProvider.CreateContext();
- return await dbContext.DeviceOptions
+ var deviceOptions = await dbContext.DeviceOptions
.AsQueryable()
.FirstOrDefaultAsync(d => d.DeviceId == deviceId)
.ConfigureAwait(false);
+
+ return deviceOptions ?? new DeviceOptions(deviceId);
}
/// <inheritdoc />