The Free Software Media System - Server Backend & API
Enable nullable for more files
Bond_009645825db36f2
diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.csindex 8270c2e84c..b00a519229 100644--- a/Emby.Server.Implementations/Collections/CollectionManager.cs+++ b/Emby.Server.Implementations/Collections/CollectionManager.cs@@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.Collectionsvar libraryOptions = new LibraryOptions{- PathInfos = new[] { new MediaPathInfo { Path = path } },+ PathInfos = new[] { new MediaPathInfo(path) },EnableRealtimeMonitor = false,SaveLocalMetadata = true};diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.csindex 13fb8b2fd5..0cde8101c5 100644--- a/Emby.Server.Implementations/Library/LibraryManager.cs+++ b/Emby.Server.Implementations/Library/LibraryManager.cs@@ -3173,10 +3173,7 @@ namespace Emby.Server.Implementations.Library{if (!list.Any(i => string.Equals(i.Path, location, StringComparison.Ordinal))){- list.Add(new MediaPathInfo- {- Path = location- });+ list.Add(new MediaPathInfo(location));}}diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.csindex 3fcadf5b1b..bb3d635d12 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs@@ -1,5 +1,3 @@-#nullable disable-#pragma warning disable CS1591using System;@@ -33,7 +31,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVreturn targetFile;}- public Task Record(IDirectStreamProvider directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)+ public Task Record(IDirectStreamProvider? directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken){if (directStreamProvider != null){@@ -45,7 +43,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVprivate async Task RecordFromDirectStreamProvider(IDirectStreamProvider directStreamProvider, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken){- Directory.CreateDirectory(Path.GetDirectoryName(targetFile));+ Directory.CreateDirectory(Path.GetDirectoryName(targetFile) ?? throw new ArgumentException("Path can't be a root directory.", nameof(targetFile)));// use FileShare.None as this bypasses dotnet bug dotnet/runtime#42790 .using (var output = new FileStream(targetFile, FileMode.Create, FileAccess.Write, FileShare.None))@@ -71,7 +69,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV_logger.LogInformation("Opened recording stream from tuner provider");- Directory.CreateDirectory(Path.GetDirectoryName(targetFile));+ Directory.CreateDirectory(Path.GetDirectoryName(targetFile) ?? throw new ArgumentException("Path can't be a root directory.", nameof(targetFile)));// use FileShare.None as this bypasses dotnet bug dotnet/runtime#42790 .await using var output = new FileStream(targetFile, FileMode.Create, FileAccess.Write, FileShare.None);diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.csindex 7970631201..f2b9f3cb90 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs@@ -159,8 +159,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVtry{var recordingFolders = GetRecordingFolders().ToArray();- var virtualFolders = _libraryManager.GetVirtualFolders()- .ToList();+ var virtualFolders = _libraryManager.GetVirtualFolders();var allExistingPaths = virtualFolders.SelectMany(i => i.Locations).ToList();@@ -177,7 +176,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVcontinue;}- var mediaPathInfos = pathsToCreate.Select(i => new MediaPathInfo { Path = i }).ToArray();+ var mediaPathInfos = pathsToCreate.Select(i => new MediaPathInfo(i)).ToArray();var libraryOptions = new LibraryOptions{@@ -210,7 +209,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVforeach (var path in pathsToRemove){- await RemovePathFromLibrary(path).ConfigureAwait(false);+ await RemovePathFromLibraryAsync(path).ConfigureAwait(false);}}catch (Exception ex)@@ -219,13 +218,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV}}- private async Task RemovePathFromLibrary(string path)+ private async Task RemovePathFromLibraryAsync(string path){_logger.LogDebug("Removing path from library: {0}", path);var requiresRefresh = false;- var virtualFolders = _libraryManager.GetVirtualFolders()- .ToList();+ var virtualFolders = _libraryManager.GetVirtualFolders();foreach (var virtualFolder in virtualFolders){@@ -460,7 +458,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVif (!string.IsNullOrWhiteSpace(tunerChannel.TunerChannelId)){var tunerChannelId = tunerChannel.TunerChannelId;- if (tunerChannelId.IndexOf(".json.schedulesdirect.org", StringComparison.OrdinalIgnoreCase) != -1)+ if (tunerChannelId.Contains(".json.schedulesdirect.org", StringComparison.OrdinalIgnoreCase)){tunerChannelId = tunerChannelId.Replace(".json.schedulesdirect.org", string.Empty, StringComparison.OrdinalIgnoreCase).TrimStart('I');}@@ -620,8 +618,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVif (existingTimer != null){- if (existingTimer.Status == RecordingStatus.Cancelled ||- existingTimer.Status == RecordingStatus.Completed)+ if (existingTimer.Status == RecordingStatus.Cancelled+ || existingTimer.Status == RecordingStatus.Completed){existingTimer.Status = RecordingStatus.New;existingTimer.IsManual = true;@@ -913,18 +911,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVvar epgChannel = await GetEpgChannelFromTunerChannel(provider.Item1, provider.Item2, channel, cancellationToken).ConfigureAwait(false);- List<ProgramInfo> programs;-if (epgChannel == null){_logger.LogDebug("EPG channel not found for tuner channel {0}-{1} from {2}-{3}", channel.Number, channel.Name, provider.Item1.Name, provider.Item2.ListingsId ?? string.Empty);- programs = new List<ProgramInfo>();+ continue;}- else- {- programs = (await provider.Item1.GetProgramsAsync(provider.Item2, epgChannel.Id, startDateUtc, endDateUtc, cancellationToken)++ List<ProgramInfo> programs = (await provider.Item1.GetProgramsAsync(provider.Item2, epgChannel.Id, startDateUtc, endDateUtc, cancellationToken).ConfigureAwait(false)).ToList();- }// Replace the value that came from the provider with a normalized valueforeach (var program in programs)@@ -940,7 +934,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV}}- return new List<ProgramInfo>();+ return Enumerable.Empty<ProgramInfo>();}private List<Tuple<IListingsProvider, ListingsProviderInfo>> GetListingProviders()@@ -1292,7 +1286,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV_logger.LogInformation("Beginning recording. Will record for {0} minutes.", duration.TotalMinutes.ToString(CultureInfo.InvariantCulture));- _logger.LogInformation("Writing file to path: " + recordPath);+ _logger.LogInformation("Writing file to: {Path}", recordPath);Action onStarted = async () =>{@@ -1417,13 +1411,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVprivate void TriggerRefresh(string path){- _logger.LogInformation("Triggering refresh on {path}", path);+ _logger.LogInformation("Triggering refresh on {Path}", path);var item = GetAffectedBaseItem(Path.GetDirectoryName(path));if (item != null){- _logger.LogInformation("Refreshing recording parent {path}", item.Path);+ _logger.LogInformation("Refreshing recording parent {Path}", item.Path);_providerManager.QueueRefresh(item.Id,@@ -1458,7 +1452,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVif (item.GetType() == typeof(Folder) && string.Equals(item.Path, parentPath, StringComparison.OrdinalIgnoreCase)){var parentItem = item.GetParent();- if (parentItem != null && !(parentItem is AggregateFolder))+ if (parentItem != null && parentItem is not AggregateFolder){item = parentItem;}@@ -1512,8 +1506,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVDeleteLibraryItemsForTimers(timersToDelete);- var librarySeries = _libraryManager.FindByPath(seriesPath, true) as Folder;- if (librarySeries == null)+ if (_libraryManager.FindByPath(seriesPath, true) is not Folder librarySeries){return;}@@ -1667,7 +1660,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV_logger.LogInformation("Running recording post processor {0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);- process.Exited += Process_Exited;+ process.Exited += OnProcessExited;process.Start();}catch (Exception ex)@@ -1681,7 +1674,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVreturn arguments.Replace("{path}", path, StringComparison.OrdinalIgnoreCase);}- private void Process_Exited(object sender, EventArgs e)+ private void OnProcessExited(object sender, EventArgs e){using (var process = (Process)sender){@@ -2239,7 +2232,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVvar enabledTimersForSeries = new List<TimerInfo>();foreach (var timer in allTimers){- var existingTimer = _timerProvider.GetTimer(timer.Id)+ var existingTimer = _timerProvider.GetTimer(timer.Id)?? (string.IsNullOrWhiteSpace(timer.ProgramId)? null: _timerProvider.GetTimerByProgramId(timer.ProgramId));diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.csindex 93781cb7ba..e10bc76470 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs@@ -319,11 +319,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV}}}- catch (ObjectDisposedException)- {- // TODO Investigate and properly fix.- // Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux- }catch (Exception ex){_logger.LogError(ex, "Error reading ffmpeg recording log");diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EpgChannelData.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EpgChannelData.csindex 0ec52a9598..20a8213a77 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EpgChannelData.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EpgChannelData.cs@@ -8,7 +8,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV{internal class EpgChannelData{-private readonly Dictionary<string, ChannelInfo> _channelsById;private readonly Dictionary<string, ChannelInfo> _channelsByNumber;diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.csindex 4712724d67..dfe3517b22 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs@@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV/// <summary>/// Records the specified media source./// </summary>- Task Record(IDirectStreamProvider directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken);+ Task Record(IDirectStreamProvider? directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken);string GetOutputPath(MediaSourceInfo mediaSource, string targetFile);}diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.csindex 6c52a9a73d..a861e6ae44 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs@@ -1,5 +1,3 @@-#nullable disable-#pragma warning disable CS1591using System;@@ -23,7 +21,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV{}- public event EventHandler<GenericEventArgs<TimerInfo>> TimerFired;+ public event EventHandler<GenericEventArgs<TimerInfo>>? TimerFired;public void RestartTimers(){@@ -145,9 +143,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV}}- private void TimerCallback(object state)+ private void TimerCallback(object? state){- var timerId = (string)state;+ var timerId = (string?)state ?? throw new ArgumentNullException(nameof(state));var timer = GetAll().FirstOrDefault(i => string.Equals(i.Id, timerId, StringComparison.OrdinalIgnoreCase));if (timer != null)@@ -156,12 +154,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV}}- public TimerInfo GetTimer(string id)+ public TimerInfo? GetTimer(string id){return GetAll().FirstOrDefault(r => string.Equals(r.Id, id, StringComparison.OrdinalIgnoreCase));}- public TimerInfo GetTimerByProgramId(string programId)+ public TimerInfo? GetTimerByProgramId(string programId){return GetAll().FirstOrDefault(r => string.Equals(r.ProgramId, programId, StringComparison.OrdinalIgnoreCase));}diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.csindex b7639a51ce..d029d56c87 100644--- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs+++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs@@ -14,8 +14,8 @@ using System.Text;using System.Text.Json;using System.Threading;using System.Threading.Tasks;-using MediaBrowser.Common;using Jellyfin.Extensions.Json;+using MediaBrowser.Common;using MediaBrowser.Common.Net;using MediaBrowser.Controller.LiveTv;using MediaBrowser.Model.Cryptography;diff --git a/Jellyfin.Api/Controllers/LibraryStructureController.cs b/Jellyfin.Api/Controllers/LibraryStructureController.csindex be9127dd39..ec1170411c 100644--- a/Jellyfin.Api/Controllers/LibraryStructureController.cs+++ b/Jellyfin.Api/Controllers/LibraryStructureController.cs@@ -84,7 +84,7 @@ namespace Jellyfin.Api.Controllersif (paths != null && paths.Length > 0){- libraryOptions.PathInfos = paths.Select(i => new MediaPathInfo { Path = i }).ToArray();+ libraryOptions.PathInfos = paths.Select(i => new MediaPathInfo(i)).ToArray();}await _libraryManager.AddVirtualFolder(name, collectionType, libraryOptions, refreshLibrary).ConfigureAwait(false);@@ -212,7 +212,7 @@ namespace Jellyfin.Api.Controllerstry{- var mediaPath = mediaPathDto.PathInfo ?? new MediaPathInfo { Path = mediaPathDto.Path };+ var mediaPath = mediaPathDto.PathInfo ?? new MediaPathInfo(mediaPathDto.Path ?? throw new ArgumentException("PathInfo and Path can't both be null."));_libraryManager.AddMediaPath(mediaPathDto.Name, mediaPath);}diff --git a/MediaBrowser.Model/Configuration/MediaPathInfo.cs b/MediaBrowser.Model/Configuration/MediaPathInfo.csindex 4f311c58f0..d096defcb8 100644--- a/MediaBrowser.Model/Configuration/MediaPathInfo.cs+++ b/MediaBrowser.Model/Configuration/MediaPathInfo.cs@@ -1,12 +1,16 @@-#nullable disable#pragma warning disable CS1591namespace MediaBrowser.Model.Configuration{public class MediaPathInfo{+ public MediaPathInfo(string path)+ {+ Path = path;+ }+public string Path { get; set; }- public string NetworkPath { get; set; }+ public string? NetworkPath { get; set; }}}diff --git a/MediaBrowser.XbmcMetadata/Configuration/NfoConfigurationFactory.cs b/MediaBrowser.XbmcMetadata/Configuration/NfoConfigurationFactory.csindex 8325bfdbd5..c73989e761 100644--- a/MediaBrowser.XbmcMetadata/Configuration/NfoConfigurationFactory.cs+++ b/MediaBrowser.XbmcMetadata/Configuration/NfoConfigurationFactory.cs@@ -15,8 +15,8 @@ namespace MediaBrowser.XbmcMetadata.Configuration{new ConfigurationStore{- ConfigurationType = typeof(XbmcMetadataOptions),- Key = "xbmcmetadata"+ ConfigurationType = typeof(XbmcMetadataOptions),+ Key = "xbmcmetadata"}};}