aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/LiveStreamHelper.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2024-03-17 18:00:10 +0100
committerGitHub <noreply@github.com>2024-03-17 18:00:10 +0100
commitadb08c0aaa5c35629cf19f01b825c60d99ad2a0c (patch)
treee5404cbf08f46ff22d2e6c75031c612d1e7ff0b2 /Emby.Server.Implementations/Library/LiveStreamHelper.cs
parent8070aabe1bb6fad0f42c33a785ffafe94bcfc329 (diff)
parent651681c27630af0fd0852980ac473ce570805dc3 (diff)
Merge pull request #11149 from Bond-009/nullable4
Enable nullable for more files
Diffstat (limited to 'Emby.Server.Implementations/Library/LiveStreamHelper.cs')
-rw-r--r--Emby.Server.Implementations/Library/LiveStreamHelper.cs10
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))
{