Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some warnings #6289

Merged
merged 1 commit into from Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions Emby.Server.Implementations/ApplicationHost.cs
Expand Up @@ -1118,7 +1118,7 @@ public IEnumerable<WakeOnLanInfo> GetWakeOnLanInfo()
.Select(i => new WakeOnLanInfo(i))
.ToList();

public PublicSystemInfo GetPublicSystemInfo(IPAddress source)
public PublicSystemInfo GetPublicSystemInfo(IPAddress address)
{
return new PublicSystemInfo
{
Expand All @@ -1127,7 +1127,7 @@ public PublicSystemInfo GetPublicSystemInfo(IPAddress source)
Id = SystemId,
OperatingSystem = OperatingSystem.Id.ToString(),
ServerName = FriendlyName,
LocalAddress = GetSmartApiUrl(source),
LocalAddress = GetSmartApiUrl(address),
StartupWizardCompleted = ConfigurationManager.CommonConfiguration.IsStartupWizardCompleted
};
}
Expand All @@ -1136,7 +1136,7 @@ public PublicSystemInfo GetPublicSystemInfo(IPAddress source)
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))
Expand All @@ -1145,7 +1145,7 @@ public string GetSmartApiUrl(IPAddress ipAddress, int? port = null)
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))
{
Expand Down Expand Up @@ -1208,14 +1208,14 @@ public string GetLoopbackHttpApiUrl()
}

/// <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('/');
Expand Down
5 changes: 3 additions & 2 deletions Emby.Server.Implementations/Library/LibraryManager.cs
Expand Up @@ -2540,9 +2540,10 @@ public bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh
{
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
Expand Down
Expand Up @@ -65,7 +65,7 @@ public Task Execute(CancellationToken cancellationToken, IProgress<double> progr
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);
}

Expand Down
13 changes: 4 additions & 9 deletions MediaBrowser.Common/Net/IPHost.cs
Expand Up @@ -79,16 +79,11 @@ public override IPAddress Address
/// </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>
Expand Down
16 changes: 1 addition & 15 deletions MediaBrowser.Controller/Entities/BaseItem.cs
Expand Up @@ -771,19 +771,6 @@ public bool EnableMediaSourceDisplay
[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;
Expand Down Expand Up @@ -822,8 +809,7 @@ public T FindParent<T>()
{
foreach (var parent in GetParents())
{
var item = parent as T;
if (item != null)
if (parent is T item)
{
return item;
}
Expand Down
85 changes: 44 additions & 41 deletions MediaBrowser.Controller/Entities/UserView.cs
Expand Up @@ -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>
Expand All @@ -30,12 +49,22 @@ public class UserView : Folder, IHasCollectionType
/// </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()
{
Expand All @@ -53,17 +82,13 @@ public override IEnumerable<Guid> GetIdsForAncestorQuery()
}
}

[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;
Expand All @@ -81,6 +106,7 @@ protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery que
.GetUserItems(parent, this, CollectionType, query);
}

/// <inheritdoc />
public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query)
{
query ??= new InternalItemsQuery(user);
Expand All @@ -91,16 +117,19 @@ public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren
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);
Expand All @@ -111,32 +140,26 @@ public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalIt
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)
Expand All @@ -145,39 +168,19 @@ public static bool IsEligibleForGrouping(Folder folder)
&& 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;
}
}
5 changes: 3 additions & 2 deletions tests/Jellyfin.MediaEncoding.Tests/FFprobeParserTests.cs
Expand Up @@ -14,9 +14,10 @@ public class FFprobeParserTests
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);
}
}
}
Expand Down