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/Library/LiveStreamHelper.cs | |
| parent | 9db093b9d9d3a2e07a329781864e9da95b49dfda (diff) | |
Enable nullable for more files
Diffstat (limited to 'Emby.Server.Implementations/Library/LiveStreamHelper.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/LiveStreamHelper.cs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Emby.Server.Implementations/Library/LiveStreamHelper.cs b/Emby.Server.Implementations/Library/LiveStreamHelper.cs index d4aeae41a..0ebfe3ae7 100644 --- a/Emby.Server.Implementations/Library/LiveStreamHelper.cs +++ b/Emby.Server.Implementations/Library/LiveStreamHelper.cs @@ -1,5 +1,3 @@ -#nullable disable - #pragma warning disable CS1591 using System; @@ -37,16 +35,16 @@ namespace Emby.Server.Implementations.Library _appPaths = appPaths; } - public async Task AddMediaInfoWithProbe(MediaSourceInfo mediaSource, bool isAudio, string cacheKey, bool addProbeDelay, CancellationToken cancellationToken) + public async Task AddMediaInfoWithProbe(MediaSourceInfo mediaSource, bool isAudio, string? cacheKey, bool addProbeDelay, CancellationToken cancellationToken) { var originalRuntime = mediaSource.RunTimeTicks; var now = DateTime.UtcNow; - MediaInfo mediaInfo = null; + MediaInfo? mediaInfo = null; var cacheFilePath = string.IsNullOrEmpty(cacheKey) ? null : Path.Combine(_appPaths.CachePath, "mediainfo", cacheKey.GetMD5().ToString("N", CultureInfo.InvariantCulture) + ".json"); - if (!string.IsNullOrEmpty(cacheKey)) + if (cacheFilePath is not null) { try { @@ -91,7 +89,7 @@ namespace Emby.Server.Implementations.Library if (cacheFilePath is not null) { - Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath) ?? throw new InvalidOperationException("Path can't be a root directory.")); FileStream createStream = AsyncFile.OpenWrite(cacheFilePath); await using (createStream.ConfigureAwait(false)) { |
