diff options
| author | Bond-009 <bond.009@outlook.com> | 2024-03-17 18:00:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-17 18:00:10 +0100 |
| commit | adb08c0aaa5c35629cf19f01b825c60d99ad2a0c (patch) | |
| tree | e5404cbf08f46ff22d2e6c75031c612d1e7ff0b2 /Emby.Server.Implementations/Devices | |
| parent | 8070aabe1bb6fad0f42c33a785ffafe94bcfc329 (diff) | |
| parent | 651681c27630af0fd0852980ac473ce570805dc3 (diff) | |
Merge pull request #11149 from Bond-009/nullable4
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) { |
