The Free Software Media System - Server Backend & API
Fix some warnings
Bond_009915141f196d6
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex 82995deb30..b73b6bb004 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -1118,7 +1118,7 @@ namespace Emby.Server.Implementations.Select(i => new WakeOnLanInfo(i)).ToList();- public PublicSystemInfo GetPublicSystemInfo(IPAddress source)+ public PublicSystemInfo GetPublicSystemInfo(IPAddress address){return new PublicSystemInfo{@@ -1127,7 +1127,7 @@ namespace Emby.Server.ImplementationsId = SystemId,OperatingSystem = OperatingSystem.Id.ToString(),ServerName = FriendlyName,- LocalAddress = GetSmartApiUrl(source),+ LocalAddress = GetSmartApiUrl(address),StartupWizardCompleted = ConfigurationManager.CommonConfiguration.IsStartupWizardCompleted};}@@ -1136,7 +1136,7 @@ namespace Emby.Server.Implementationspublic bool ListenWithHttps => Certificate != null && ConfigurationManager.GetNetworkConfiguration().EnableHttps;/// <inheritdoc/>- public string GetSmartApiUrl(IPAddress ipAddress, int? port = null)+ public string GetSmartApiUrl(IPAddress remoteAddr, int? port = null){// Published server ends with a /if (!string.IsNullOrEmpty(PublishedServerUrl))@@ -1145,7 +1145,7 @@ namespace Emby.Server.Implementationsreturn PublishedServerUrl.Trim('/');}- string smart = NetManager.GetBindInterface(ipAddress, out port);+ string smart = NetManager.GetBindInterface(remoteAddr, out port);// If the smartAPI doesn't start with http then treat it as a host or ip.if (smart.StartsWith("http", StringComparison.OrdinalIgnoreCase)){@@ -1208,14 +1208,14 @@ namespace Emby.Server.Implementations}/// <inheritdoc/>- public string GetLocalApiUrl(string host, string scheme = null, int? port = null)+ public string GetLocalApiUrl(string hostname, string scheme = null, int? port = null){// NOTE: If no BaseUrl is set then UriBuilder appends a trailing slash, but if there is no BaseUrl it does// not. For consistency, always trim the trailing slash.return new UriBuilder{Scheme = scheme ?? (ListenWithHttps ? Uri.UriSchemeHttps : Uri.UriSchemeHttp),- Host = host,+ Host = hostname,Port = port ?? (ListenWithHttps ? HttpsPort : HttpPort),Path = ConfigurationManager.GetNetworkConfiguration().BaseUrl}.ToString().TrimEnd('/');diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.csindex d806373329..13fb8b2fd5 100644--- a/Emby.Server.Implementations/Library/LibraryManager.cs+++ b/Emby.Server.Implementations/Library/LibraryManager.cs@@ -2540,9 +2540,10 @@ namespace Emby.Server.Implementations.Library{episodeInfo = resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming);// Resolve from parent folder if it's not the Season folder- if (episodeInfo == null && episode.Parent.GetType() == typeof(Folder))+ var parent = episode.GetParent();+ if (episodeInfo == null && parent.GetType() == typeof(Folder)){- episodeInfo = resolver.Resolve(episode.Parent.Path, true, null, null, isAbsoluteNaming);+ episodeInfo = resolver.Resolve(parent.Path, true, null, null, isAbsoluteNaming);if (episodeInfo != null){// add the containerdiff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/CleanActivityLogTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/CleanActivityLogTask.csindex 50ba9bc899..19600b1e64 100644--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/CleanActivityLogTask.cs+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/CleanActivityLogTask.cs@@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasksthrow new Exception($"Activity Log Retention days must be at least 0. Currently: {retentionDays}");}- var startDate = DateTime.UtcNow.AddDays(retentionDays.Value * -1);+ var startDate = DateTime.UtcNow.AddDays(-retentionDays.Value);return _activityManager.CleanAsync(startDate);}diff --git a/MediaBrowser.Common/Net/IPHost.cs b/MediaBrowser.Common/Net/IPHost.csindex 5db8817ee6..d78d7def2b 100644--- a/MediaBrowser.Common/Net/IPHost.cs+++ b/MediaBrowser.Common/Net/IPHost.cs@@ -79,16 +79,11 @@ namespace MediaBrowser.Common.Net/// </summary>public override byte PrefixLength{- get- {- return (byte)(ResolveHost() ? 128 : 32);- }+ get => (byte)(ResolveHost() ? 128 : 32);- set- {- // Not implemented, as a host object can only have a prefix length of 128 (IPv6) or 32 (IPv4) prefix length,- // which is automatically determined by it's IP type. Anything else is meaningless.- }+ // Not implemented, as a host object can only have a prefix length of 128 (IPv6) or 32 (IPv4) prefix length,+ // which is automatically determined by it's IP type. Anything else is meaningless.+ set => throw new NotImplementedException();}/// <summary>diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex e5be5421a2..23b97f70c6 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -771,19 +771,6 @@ namespace MediaBrowser.Controller.Entities[JsonIgnore]public Guid ParentId { get; set; }- /// <summary>- /// Gets or sets the parent.- /// </summary>- /// <value>The parent.</value>- [JsonIgnore]- public Folder Parent- {- get => GetParent() as Folder;- set- {- }- }-public void SetParent(Folder parent){ParentId = parent == null ? Guid.Empty : parent.Id;@@ -822,8 +809,7 @@ namespace MediaBrowser.Controller.Entities{foreach (var parent in GetParents()){- var item = parent as T;- if (item != null)+ if (parent is T item){return item;}diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.csindex 57dc9b59ba..62f3c4b557 100644--- a/MediaBrowser.Controller/Entities/UserView.cs+++ b/MediaBrowser.Controller/Entities/UserView.cs@@ -15,6 +15,25 @@ namespace MediaBrowser.Controller.Entities{public class UserView : Folder, IHasCollectionType{+ private static readonly string[] _viewTypesEligibleForGrouping = new string[]+ {+ Model.Entities.CollectionType.Movies,+ Model.Entities.CollectionType.TvShows,+ string.Empty+ };++ private static readonly string[] _originalFolderViewTypes = new string[]+ {+ Model.Entities.CollectionType.Books,+ Model.Entities.CollectionType.MusicVideos,+ Model.Entities.CollectionType.HomeVideos,+ Model.Entities.CollectionType.Photos,+ Model.Entities.CollectionType.Music,+ Model.Entities.CollectionType.BoxSets+ };++ public static ITVSeriesManager TVSeriesManager { get; set; }+/// <summary>/// Gets or sets the view type./// </summary>@@ -30,12 +49,22 @@ namespace MediaBrowser.Controller.Entities/// </summary>public Guid? UserId { get; set; }- public static ITVSeriesManager TVSeriesManager;-/// <inheritdoc />[JsonIgnore]public string CollectionType => ViewType;+ /// <inheritdoc />+ [JsonIgnore]+ public override bool SupportsInheritedParentImages => false;++ /// <inheritdoc />+ [JsonIgnore]+ public override bool SupportsPlayedStatus => false;++ /// <inheritdoc />+ [JsonIgnore]+ public override bool SupportsPeople => false;+/// <inheritdoc />public override IEnumerable<Guid> GetIdsForAncestorQuery(){@@ -53,17 +82,13 @@ namespace MediaBrowser.Controller.Entities}}- [JsonIgnore]- public override bool SupportsInheritedParentImages => false;-- [JsonIgnore]- public override bool SupportsPlayedStatus => false;-+ /// <inheritdoc />public override int GetChildCount(User user){return GetChildren(user, true).Count;}+ /// <inheritdoc />protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query){var parent = this as Folder;@@ -81,6 +106,7 @@ namespace MediaBrowser.Controller.Entities.GetUserItems(parent, this, CollectionType, query);}+ /// <inheritdoc />public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query){query ??= new InternalItemsQuery(user);@@ -91,16 +117,19 @@ namespace MediaBrowser.Controller.Entitiesreturn result.ToList();}+ /// <inheritdoc />public override bool CanDelete(){return false;}+ /// <inheritdoc />public override bool IsSaveLocalMetadataEnabled(){return true;}+ /// <inheritdoc />public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query){query.SetUser(user);@@ -111,32 +140,26 @@ namespace MediaBrowser.Controller.Entitiesreturn GetItemList(query);}+ /// <inheritdoc />protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user){return GetChildren(user, false);}- private static readonly string[] UserSpecificViewTypes = new string[]- {- Model.Entities.CollectionType.Playlists- };-public static bool IsUserSpecific(Folder folder){- var collectionFolder = folder as ICollectionFolder;-- if (collectionFolder == null)+ if (folder is not ICollectionFolder collectionFolder){return false;}- var supportsUserSpecific = folder as ISupportsUserSpecificView;- if (supportsUserSpecific != null && supportsUserSpecific.EnableUserSpecificView)+ if (folder is ISupportsUserSpecificView supportsUserSpecific+ && supportsUserSpecific.EnableUserSpecificView){return true;}- return UserSpecificViewTypes.Contains(collectionFolder.CollectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase);+ return string.Equals(Model.Entities.CollectionType.Playlists, collectionFolder.CollectionType, StringComparison.OrdinalIgnoreCase);}public static bool IsEligibleForGrouping(Folder folder)@@ -145,39 +168,19 @@ namespace MediaBrowser.Controller.Entities&& IsEligibleForGrouping(collectionFolder.CollectionType);}- private static string[] ViewTypesEligibleForGrouping = new string[]- {- Model.Entities.CollectionType.Movies,- Model.Entities.CollectionType.TvShows,- string.Empty- };-public static bool IsEligibleForGrouping(string viewType){- return ViewTypesEligibleForGrouping.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);+ return _viewTypesEligibleForGrouping.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);}- private static string[] OriginalFolderViewTypes = new string[]- {- Model.Entities.CollectionType.Books,- Model.Entities.CollectionType.MusicVideos,- Model.Entities.CollectionType.HomeVideos,- Model.Entities.CollectionType.Photos,- Model.Entities.CollectionType.Music,- Model.Entities.CollectionType.BoxSets- };-public static bool EnableOriginalFolder(string viewType){- return OriginalFolderViewTypes.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);+ return _originalFolderViewTypes.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);}protected override Task ValidateChildrenInternal(IProgress<double> progress, bool recursive, bool refreshChildMetadata, Providers.MetadataRefreshOptions refreshOptions, Providers.IDirectoryService directoryService, System.Threading.CancellationToken cancellationToken){return Task.CompletedTask;}-- [JsonIgnore]- public override bool SupportsPeople => false;}}diff --git a/tests/Jellyfin.MediaEncoding.Tests/FFprobeParserTests.cs b/tests/Jellyfin.MediaEncoding.Tests/FFprobeParserTests.csindex 45808375f1..2955104a27 100644--- a/tests/Jellyfin.MediaEncoding.Tests/FFprobeParserTests.cs+++ b/tests/Jellyfin.MediaEncoding.Tests/FFprobeParserTests.cs@@ -14,9 +14,10 @@ namespace Jellyfin.MediaEncoding.Testspublic async Task Test(string fileName){var path = Path.Join("Test Data", fileName);- using (var stream = File.OpenRead(path))+ await using (var stream = File.OpenRead(path)){- await JsonSerializer.DeserializeAsync<InternalMediaInfoResult>(stream, JsonDefaults.Options).ConfigureAwait(false);+ var res = await JsonSerializer.DeserializeAsync<InternalMediaInfoResult>(stream, JsonDefaults.Options).ConfigureAwait(false);+ Assert.NotNull(res);}}}