Merge pull request #6289 from Bond-009/warn33

Fix some warnings
This commit is contained in:
Bond-009 2021-07-12 23:53:52 +02:00 committed by GitHub
commit b20977dc25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 62 additions and 76 deletions

View File

@ -1117,7 +1117,7 @@ namespace Emby.Server.Implementations
.Select(i => new WakeOnLanInfo(i))
.ToList();
public PublicSystemInfo GetPublicSystemInfo(IPAddress source)
public PublicSystemInfo GetPublicSystemInfo(IPAddress address)
{
return new PublicSystemInfo
{
@ -1126,7 +1126,7 @@ namespace Emby.Server.Implementations
Id = SystemId,
OperatingSystem = OperatingSystem.Id.ToString(),
ServerName = FriendlyName,
LocalAddress = GetSmartApiUrl(source),
LocalAddress = GetSmartApiUrl(address),
StartupWizardCompleted = ConfigurationManager.CommonConfiguration.IsStartupWizardCompleted
};
}
@ -1135,7 +1135,7 @@ namespace Emby.Server.Implementations
public 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))
@ -1144,7 +1144,7 @@ namespace Emby.Server.Implementations
return 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))
{
@ -1207,14 +1207,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('/');

View File

@ -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 container

View File

@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
throw 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);
}

View File

@ -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>

View File

@ -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;
}

View File

@ -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.Entities
return 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.Entities
return 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;
}
}

View File

@ -14,9 +14,10 @@ namespace Jellyfin.MediaEncoding.Tests
public 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);
}
}
}