diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs
index 8e0fda30d9..a41ef888b0 100644
--- a/Emby.Server.Implementations/Library/UserDataManager.cs
+++ b/Emby.Server.Implementations/Library/UserDataManager.cs
@@ -1,7 +1,8 @@
+#pragma warning disable RS0030 // Do not use banned APIs
+
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Threading;
@@ -17,7 +18,6 @@ using MediaBrowser.Model.Entities;
using Microsoft.EntityFrameworkCore;
using AudioBook = MediaBrowser.Controller.Entities.AudioBook;
using Book = MediaBrowser.Controller.Entities.Book;
-#pragma warning disable RS0030 // Do not use banned APIs
namespace Emby.Server.Implementations.Library
{
@@ -100,7 +100,7 @@ namespace Emby.Server.Implementations.Library
ArgumentNullException.ThrowIfNull(item);
ArgumentNullException.ThrowIfNull(userDataDto);
- var userData = GetUserData(user, item) ?? throw new InvalidOperationException("Did not expect UserData to be null.");
+ var userData = GetUserData(user, item) ?? throw new InvalidOperationException("UserData should not be null.");
if (userDataDto.PlaybackPositionTicks.HasValue)
{
diff --git a/Jellyfin.Data/Entities/ItemValueType.cs b/Jellyfin.Data/Entities/ItemValueType.cs
index 48c5d0f305..3bae3beccd 100644
--- a/Jellyfin.Data/Entities/ItemValueType.cs
+++ b/Jellyfin.Data/Entities/ItemValueType.cs
@@ -1,11 +1,10 @@
+#pragma warning disable CA1027 // Mark enums with FlagsAttribute
namespace Jellyfin.Data.Entities;
///
/// Provides the Value types for an .
///
-#pragma warning disable CA1027 // Mark enums with FlagsAttribute
public enum ItemValueType
-#pragma warning restore CA1027 // Mark enums with FlagsAttribute
{
///
/// Artists.
diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
index 71ea8af52a..cc2b3face3 100644
--- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
@@ -1,4 +1,4 @@
-#nullable disable
+#pragma warning disable CA1826 // CA1826 Do not use Enumerable methods on Indexable collections.
using System;
using System.Collections.Generic;
@@ -80,12 +80,11 @@ namespace MediaBrowser.Providers.MediaInfo
if (!File.Exists(path))
{
- Directory.CreateDirectory(Path.GetDirectoryName(path));
-#pragma warning disable CA1826
+ var directoryName = Path.GetDirectoryName(path) ?? throw new InvalidOperationException($"Invalid path '{path}'");
+ Directory.CreateDirectory(directoryName);
var imageStream = imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).Contains("front", StringComparison.OrdinalIgnoreCase)) ??
imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).Contains("cover", StringComparison.OrdinalIgnoreCase)) ??
imageStreams.FirstOrDefault();
-#pragma warning restore CA1826
var imageStreamIndex = imageStream?.Index;
var tempFile = await _mediaEncoder.ExtractAudioImage(item.Path, imageStreamIndex, cancellationToken).ConfigureAwait(false);
diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
index bd6b40c51e..1a6dbbd7bc 100644
--- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
@@ -1,3 +1,5 @@
+#pragma warning disable CA1826 // CA1826 Do not use Enumerable methods on Indexable collections.
+
using System;
using System.Collections.Generic;
using System.Linq;
@@ -88,7 +90,6 @@ namespace MediaBrowser.Providers.MediaInfo
: TimeSpan.FromSeconds(10);
var query = new MediaStreamQuery { ItemId = item.Id, Index = item.DefaultVideoStreamIndex };
-#pragma warning disable CA1826
var videoStream = _mediaSourceManager.GetMediaStreams(query).FirstOrDefault();
if (videoStream is null)
{
@@ -96,7 +97,6 @@ namespace MediaBrowser.Providers.MediaInfo
query.Index = null;
videoStream = _mediaSourceManager.GetMediaStreams(query).FirstOrDefault();
}
-#pragma warning restore CA1826
if (videoStream is null)
{
_logger.LogInformation("Skipping image extraction: no video stream found for {Path}.", item.Path ?? string.Empty);