diff options
| author | Patrick Barron <barronpm@gmail.com> | 2021-06-19 15:24:26 -0400 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2021-06-19 15:24:26 -0400 |
| commit | 6b24cc6d1f9699f246f4f136b42ec583229ad0e2 (patch) | |
| tree | 09032b2d5b3c9f77b3355c61c484e8ed3bfd6a8c /Jellyfin.Server.Implementations/Devices | |
| parent | 3123ea2a9489caec908eb7932d73fa586235ab91 (diff) | |
Fix UpdateDeviceOptions
Diffstat (limited to 'Jellyfin.Server.Implementations/Devices')
| -rw-r--r-- | Jellyfin.Server.Implementations/Devices/DeviceManager.cs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs index 6bdf7b84e..ab3127669 100644 --- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs +++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs @@ -49,9 +49,15 @@ namespace Jellyfin.Server.Implementations.Devices public async Task UpdateDeviceOptions(string deviceId, DeviceOptions options) { await using var dbContext = _dbProvider.CreateContext(); - await dbContext.Database - .ExecuteSqlInterpolatedAsync($"UPDATE [DeviceOptions] SET [CustomName] = {options.CustomName}") - .ConfigureAwait(false); + var deviceOptions = await dbContext.DeviceOptions.AsQueryable().FirstOrDefaultAsync(dev => dev.DeviceId == deviceId).ConfigureAwait(false); + if (deviceOptions == null) + { + deviceOptions = new DeviceOptions(deviceId); + dbContext.DeviceOptions.Add(deviceOptions); + } + + deviceOptions.CustomName = options.CustomName; + await dbContext.SaveChangesAsync().ConfigureAwait(false); DeviceOptionsUpdated?.Invoke(this, new GenericEventArgs<Tuple<string, DeviceOptions>>(new Tuple<string, DeviceOptions>(deviceId, options))); } |
