diff options
| author | Bond_009 <bond.009@outlook.com> | 2024-03-13 14:56:51 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2024-03-13 14:56:51 +0100 |
| commit | 651681c27630af0fd0852980ac473ce570805dc3 (patch) | |
| tree | ea8cce2a0838d5e28e8bfec09bdecd8e313dcbd8 /Emby.Server.Implementations/Devices | |
| parent | 9db093b9d9d3a2e07a329781864e9da95b49dfda (diff) | |
Enable nullable for more files
Diffstat (limited to 'Emby.Server.Implementations/Devices')
| -rw-r--r-- | Emby.Server.Implementations/Devices/DeviceId.cs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs index b3f5549bc..2459178d8 100644 --- a/Emby.Server.Implementations/Devices/DeviceId.cs +++ b/Emby.Server.Implementations/Devices/DeviceId.cs @@ -1,5 +1,3 @@ -#nullable disable - #pragma warning disable CS1591 using System; @@ -17,19 +15,19 @@ namespace Emby.Server.Implementations.Devices private readonly ILogger<DeviceId> _logger; private readonly object _syncLock = new object(); - private string _id; + private string? _id; - public DeviceId(IApplicationPaths appPaths, ILoggerFactory loggerFactory) + public DeviceId(IApplicationPaths appPaths, ILogger<DeviceId> logger) { _appPaths = appPaths; - _logger = loggerFactory.CreateLogger<DeviceId>(); + _logger = logger; } - public string Value => _id ?? (_id = GetDeviceId()); + public string Value => _id ??= GetDeviceId(); private string CachePath => Path.Combine(_appPaths.DataPath, "device.txt"); - private string GetCachedId() + private string? GetCachedId() { try { @@ -65,7 +63,7 @@ namespace Emby.Server.Implementations.Devices { var path = CachePath; - Directory.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path) ?? throw new InvalidOperationException("Path can't be a root directory.")); lock (_syncLock) { |
