Forráskód Böngészése

GetDeviceOptions always returns an instance of DeviceOptions

Patrick Barron 3 éve
szülő
commit
bbac9ff67e

+ 1 - 1
Emby.Server.Implementations/Session/SessionManager.cs

@@ -535,7 +535,7 @@ namespace Emby.Server.Implementations.Session
             }
             }
 
 
             var deviceOptions = await _deviceManager.GetDeviceOptions(deviceId).ConfigureAwait(false);
             var deviceOptions = await _deviceManager.GetDeviceOptions(deviceId).ConfigureAwait(false);
-            if (string.IsNullOrEmpty(deviceOptions?.CustomName))
+            if (string.IsNullOrEmpty(deviceOptions.CustomName))
             {
             {
                 sessionInfo.DeviceName = deviceName;
                 sessionInfo.DeviceName = deviceName;
             }
             }

+ 0 - 6
Jellyfin.Api/Controllers/DevicesController.cs

@@ -107,12 +107,6 @@ namespace Jellyfin.Api.Controllers
             [FromQuery, Required] string id,
             [FromQuery, Required] string id,
             [FromBody, Required] DeviceOptions deviceOptions)
             [FromBody, Required] DeviceOptions deviceOptions)
         {
         {
-            var existingDeviceOptions = await _deviceManager.GetDeviceOptions(id).ConfigureAwait(false);
-            if (existingDeviceOptions == null)
-            {
-                return NotFound();
-            }
-
             await _deviceManager.UpdateDeviceOptions(id, deviceOptions).ConfigureAwait(false);
             await _deviceManager.UpdateDeviceOptions(id, deviceOptions).ConfigureAwait(false);
             return NoContent();
             return NoContent();
         }
         }

+ 4 - 2
Jellyfin.Server.Implementations/Devices/DeviceManager.cs

@@ -74,13 +74,15 @@ namespace Jellyfin.Server.Implementations.Devices
         }
         }
 
 
         /// <inheritdoc />
         /// <inheritdoc />
-        public async Task<DeviceOptions?> GetDeviceOptions(string deviceId)
+        public async Task<DeviceOptions> GetDeviceOptions(string deviceId)
         {
         {
             await using var dbContext = _dbProvider.CreateContext();
             await using var dbContext = _dbProvider.CreateContext();
-            return await dbContext.DeviceOptions
+            var deviceOptions = await dbContext.DeviceOptions
                 .AsQueryable()
                 .AsQueryable()
                 .FirstOrDefaultAsync(d => d.DeviceId == deviceId)
                 .FirstOrDefaultAsync(d => d.DeviceId == deviceId)
                 .ConfigureAwait(false);
                 .ConfigureAwait(false);
+
+            return deviceOptions ?? new DeviceOptions(deviceId);
         }
         }
 
 
         /// <inheritdoc />
         /// <inheritdoc />