The Free Software Media System - Server Backend & API
Various cleanups (#14785)
Bond-0098776a447d1c2
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.csindex e74755ec32..c69bcfef78 100644--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs@@ -108,7 +108,7 @@ namespace Emby.Server.Implementations.AppBaseprivate void CheckOrCreateMarker(string path, string markerName, bool recursive = false){var otherMarkers = GetMarkers(path, recursive).FirstOrDefault(e => Path.GetFileName(e) != markerName);- if (otherMarkers != null)+ if (otherMarkers is not null){throw new InvalidOperationException($"Exepected to find only {markerName} but found marker for {otherMarkers}.");}diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.csindex 1e3b8ea760..750346169f 100644--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs@@ -657,7 +657,7 @@ namespace Emby.Server.Implementations.Library}catch (Exception ex){- _logger.LogDebug(ex, "_jsonSerializer.DeserializeFromFile threw an exception.");+ _logger.LogDebug(ex, "Error parsing cached media info.");}finally{diff --git a/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs b/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.csindex 74d99455df..e5c3cef3d3 100644--- a/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs+++ b/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs@@ -39,7 +39,7 @@ public class BackupService : IBackupServiceReferenceHandler = ReferenceHandler.IgnoreCycles,};- private readonly Version _backupEngineVersion = Version.Parse("0.2.0");+ private readonly Version _backupEngineVersion = new Version(0, 2, 0);/// <summary>/// Initializes a new instance of the <see cref="BackupService"/> class.diff --git a/Jellyfin.Server/Filters/AdditionalModelFilter.cs b/Jellyfin.Server/Filters/AdditionalModelFilter.csindex 421eeecda0..58d37db5a5 100644--- a/Jellyfin.Server/Filters/AdditionalModelFilter.cs+++ b/Jellyfin.Server/Filters/AdditionalModelFilter.cs@@ -175,7 +175,7 @@ namespace Jellyfin.Server.Filters// Manually generate sync play GroupUpdate messages.var groupUpdateTypes = typeof(GroupUpdate<>).Assembly.GetTypes()- .Where(t => t.BaseType != null+ .Where(t => t.BaseType is not null&& t.BaseType.IsGenericType&& t.BaseType.GetGenericTypeDefinition() == typeof(GroupUpdate<>)).ToList();diff --git a/Jellyfin.Server/Migrations/JellyfinMigrationService.cs b/Jellyfin.Server/Migrations/JellyfinMigrationService.csindex fe191916c6..188d3c4a9a 100644--- a/Jellyfin.Server/Migrations/JellyfinMigrationService.cs+++ b/Jellyfin.Server/Migrations/JellyfinMigrationService.cs@@ -62,7 +62,7 @@ internal class JellyfinMigrationService#pragma warning disable CS0618 // Type or member is obsoleteMigrations = [.. typeof(IMigrationRoutine).Assembly.GetTypes().Where(e => typeof(IMigrationRoutine).IsAssignableFrom(e) || typeof(IAsyncMigrationRoutine).IsAssignableFrom(e)).Select(e => (Type: e, Metadata: e.GetCustomAttribute<JellyfinMigrationAttribute>(), Backup: e.GetCustomAttributes<JellyfinMigrationBackupAttribute>()))- .Where(e => e.Metadata != null)+ .Where(e => e.Metadata is not null).GroupBy(e => e.Metadata!.Stage).Select(f =>{@@ -137,7 +137,7 @@ internal class JellyfinMigrationServicevar migrationOptions = File.Exists(migrationConfigPath)? (MigrationOptions)xmlSerializer.DeserializeFromFile(typeof(MigrationOptions), migrationConfigPath)!: null;- if (migrationOptions != null && migrationOptions.Applied.Count > 0)+ if (migrationOptions is not null && migrationOptions.Applied.Count > 0){logger.LogInformation("Old migration style migration.xml detected. Migrate now.");try@@ -383,7 +383,7 @@ internal class JellyfinMigrationService}}- if (backupInstruction.JellyfinDb && _jellyfinDatabaseProvider != null)+ if (backupInstruction.JellyfinDb && _jellyfinDatabaseProvider is not null){logger.LogInformation("A migration will attempt to modify the jellyfin.db, will attempt to backup the file now.");_backupKey = (_backupKey.LibraryDb, await _jellyfinDatabaseProvider.MigrationBackupFast(CancellationToken.None).ConfigureAwait(false), _backupKey.FullBackup);diff --git a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.csindex e04a2737a6..e8ff00dd2f 100644--- a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs+++ b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs@@ -1189,7 +1189,7 @@ internal class MigrateLibraryDb : IDatabaseMigrationRoutineItemId = baseItemId,Id = Guid.NewGuid(),Path = e.Path,- Blurhash = e.BlurHash != null ? Encoding.UTF8.GetBytes(e.BlurHash) : null,+ Blurhash = e.BlurHash is not null ? Encoding.UTF8.GetBytes(e.BlurHash) : null,DateModified = e.DateModified,Height = e.Height,Width = e.Width,diff --git a/Jellyfin.Server/ServerSetupApp/SetupServer.cs b/Jellyfin.Server/ServerSetupApp/SetupServer.csindex 92e0129409..72626e8532 100644--- a/Jellyfin.Server/ServerSetupApp/SetupServer.cs+++ b/Jellyfin.Server/ServerSetupApp/SetupServer.cs@@ -98,7 +98,7 @@ public sealed class SetupServer : IDisposablevar maxLevel = logEntry.LogLevel;var stack = new Stack<StartupLogTopic>(children);- while (maxLevel != LogLevel.Error && stack.Count > 0 && (logEntry = stack.Pop()) != null) // error is the highest inherted error level.+ while (maxLevel != LogLevel.Error && stack.Count > 0 && (logEntry = stack.Pop()) is not null) // error is the highest inherted error level.{maxLevel = maxLevel < logEntry.LogLevel ? logEntry.LogLevel : maxLevel;foreach (var child in logEntry.Children)diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.csindex 3f94f54c3c..18646ec5dc 100644--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs@@ -932,12 +932,10 @@ namespace MediaBrowser.MediaEncoding.Probing}var frameInfo = frameInfoList?.FirstOrDefault(i => i.StreamIndex == stream.Index);- if (frameInfo?.SideDataList != null)+ if (frameInfo?.SideDataList is not null+ && frameInfo.SideDataList.Any(data => string.Equals(data.SideDataType, "HDR Dynamic Metadata SMPTE2094-40 (HDR10+)", StringComparison.OrdinalIgnoreCase))){- if (frameInfo.SideDataList.Any(data => string.Equals(data.SideDataType, "HDR Dynamic Metadata SMPTE2094-40 (HDR10+)", StringComparison.OrdinalIgnoreCase)))- {- stream.Hdr10PlusPresentFlag = true;- }+ stream.Hdr10PlusPresentFlag = true;}}else if (streamInfo.CodecType == CodecType.Data)diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.csindex 8bef9bd74e..ab072be03f 100644--- a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs+++ b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbMovieProvider.cs@@ -213,15 +213,18 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Moviesvar releases = movieResult.Releases.Countries.Where(i => !string.IsNullOrWhiteSpace(i.Certification)).ToList();var ourRelease = releases.FirstOrDefault(c => string.Equals(c.Iso_3166_1, info.MetadataCountryCode, StringComparison.OrdinalIgnoreCase));- var usRelease = releases.FirstOrDefault(c => string.Equals(c.Iso_3166_1, "US", StringComparison.OrdinalIgnoreCase));if (ourRelease is not null){movie.OfficialRating = TmdbUtils.BuildParentalRating(ourRelease.Iso_3166_1, ourRelease.Certification);}- else if (usRelease is not null)+ else{- movie.OfficialRating = usRelease.Certification;+ var usRelease = releases.FirstOrDefault(c => string.Equals(c.Iso_3166_1, "US", StringComparison.OrdinalIgnoreCase));+ if (usRelease is not null)+ {+ movie.OfficialRating = usRelease.Certification;+ }}}