Merge pull request #6156 from Bond-009/minor14

Minor fixes
This commit is contained in:
Claus Vium 2021-06-07 23:09:50 +02:00 committed by GitHub
commit ed2f08d05f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 51 additions and 52 deletions

View File

@ -394,7 +394,7 @@ namespace Emby.Server.Implementations.Plugins
Category = packageInfo.Category,
Changelog = versionInfo.Changelog ?? string.Empty,
Description = packageInfo.Description,
Id = new Guid(packageInfo.Id),
Id = packageInfo.Id,
Name = packageInfo.Name,
Overview = packageInfo.Overview,
Owner = packageInfo.Owner,

View File

@ -103,12 +103,12 @@ namespace Emby.Server.Implementations.Updates
public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal;
/// <inheritdoc />
public async Task<IList<PackageInfo>> GetPackages(string manifestName, string manifest, bool filterIncompatible, CancellationToken cancellationToken = default)
public async Task<PackageInfo[]> GetPackages(string manifestName, string manifest, bool filterIncompatible, CancellationToken cancellationToken = default)
{
try
{
List<PackageInfo>? packages = await _httpClientFactory.CreateClient(NamedClient.Default)
.GetFromJsonAsync<List<PackageInfo>>(new Uri(manifest), _jsonSerializerOptions, cancellationToken).ConfigureAwait(false);
PackageInfo[]? packages = await _httpClientFactory.CreateClient(NamedClient.Default)
.GetFromJsonAsync<PackageInfo[]>(new Uri(manifest), _jsonSerializerOptions, cancellationToken).ConfigureAwait(false);
if (packages == null)
{
@ -181,20 +181,14 @@ namespace Emby.Server.Implementations.Updates
// Where repositories have the same content, the details from the first is taken.
foreach (var package in await GetPackages(repository.Name ?? "Unnamed Repo", repository.Url, true, cancellationToken).ConfigureAwait(true))
{
if (!Guid.TryParse(package.Id, out var packageGuid))
{
// Package doesn't have a valid GUID, skip.
continue;
}
var existing = FilterPackages(result, package.Name, packageGuid).FirstOrDefault();
var existing = FilterPackages(result, package.Name, package.Id).FirstOrDefault();
// Remove invalid versions from the valid package.
for (var i = package.Versions.Count - 1; i >= 0; i--)
{
var version = package.Versions[i];
var plugin = _pluginManager.GetPlugin(packageGuid, version.VersionNumber);
var plugin = _pluginManager.GetPlugin(package.Id, version.VersionNumber);
if (plugin != null)
{
await _pluginManager.GenerateManifest(package, version.VersionNumber, plugin.Path, plugin.Manifest.Status).ConfigureAwait(false);
@ -233,7 +227,7 @@ namespace Emby.Server.Implementations.Updates
public IEnumerable<PackageInfo> FilterPackages(
IEnumerable<PackageInfo> availablePackages,
string? name = null,
Guid? id = default,
Guid id = default,
Version? specificVersion = null)
{
if (name != null)
@ -241,9 +235,9 @@ namespace Emby.Server.Implementations.Updates
availablePackages = availablePackages.Where(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
}
if (id != Guid.Empty)
if (id != default)
{
availablePackages = availablePackages.Where(x => Guid.Parse(x.Id) == id);
availablePackages = availablePackages.Where(x => x.Id == id);
}
if (specificVersion != null)
@ -258,7 +252,7 @@ namespace Emby.Server.Implementations.Updates
public IEnumerable<InstallationInfo> GetCompatibleVersions(
IEnumerable<PackageInfo> availablePackages,
string? name = null,
Guid? id = default,
Guid id = default,
Version? minVersion = null,
Version? specificVersion = null)
{
@ -288,7 +282,7 @@ namespace Emby.Server.Implementations.Updates
yield return new InstallationInfo
{
Changelog = v.Changelog,
Id = new Guid(package.Id),
Id = package.Id,
Name = package.Name,
Version = v.VersionNumber,
SourceUrl = v.SourceUrl,

View File

@ -25,7 +25,7 @@ namespace MediaBrowser.Common.Updates
/// <param name="filterIncompatible">Filter out incompatible plugins.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{IReadOnlyList{PackageInfo}}.</returns>
Task<IList<PackageInfo>> GetPackages(string manifestName, string manifest, bool filterIncompatible, CancellationToken cancellationToken = default);
Task<PackageInfo[]> GetPackages(string manifestName, string manifest, bool filterIncompatible, CancellationToken cancellationToken = default);
/// <summary>
/// Gets all available packages that are supported by this version.
@ -45,7 +45,7 @@ namespace MediaBrowser.Common.Updates
IEnumerable<PackageInfo> FilterPackages(
IEnumerable<PackageInfo> availablePackages,
string? name = null,
Guid? id = default,
Guid id = default,
Version? specificVersion = null);
/// <summary>
@ -60,7 +60,7 @@ namespace MediaBrowser.Common.Updates
IEnumerable<InstallationInfo> GetCompatibleVersions(
IEnumerable<PackageInfo> availablePackages,
string? name = null,
Guid? id = default,
Guid id = default,
Version? minVersion = null,
Version? specificVersion = null);

View File

@ -1,6 +1,4 @@
#pragma warning disable CA1040 // Avoid empty interfaces
namespace MediaBrowser.Controller.Channels
namespace MediaBrowser.Controller.Channels
{
/// <summary>
/// Disable media source display.

View File

@ -1,6 +1,4 @@
#pragma warning disable CA1040 // Avoid empty interfaces
namespace MediaBrowser.Controller.Channels
namespace MediaBrowser.Controller.Channels
{
/// <summary>
/// Channel supports media probe.

View File

@ -1,5 +1,3 @@
#pragma warning disable CA1040 // Avoid empty interfaces
namespace MediaBrowser.Controller.Entities
{
/// <summary>

View File

@ -1,5 +1,3 @@
#pragma warning disable CA1040 // Avoid empty interfaces
namespace MediaBrowser.Controller.Entities
{
/// <summary>

View File

@ -1,6 +1,4 @@
#pragma warning disable CA1040 // Avoid empty interfaces
namespace MediaBrowser.Controller.Plugins
namespace MediaBrowser.Controller.Plugins
{
/// <summary>
/// Indicates that a <see cref="IServerEntryPoint"/> should be invoked as a pre-startup task.

View File

@ -1,5 +1,3 @@
#pragma warning disable CA1040 // Avoid empty interfaces
namespace MediaBrowser.Controller.Providers
{
/// <summary>

View File

@ -1,4 +1,3 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@ -16,7 +15,6 @@ namespace MediaBrowser.Model.Updates
public PackageInfo()
{
Versions = Array.Empty<VersionInfo>();
Id = string.Empty;
Category = string.Empty;
Name = string.Empty;
Overview = string.Empty;
@ -65,7 +63,7 @@ namespace MediaBrowser.Model.Updates
/// </summary>
/// <value>The name.</value>
[JsonPropertyName("guid")]
public string Id { get; set; }
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the versions.

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
@ -46,12 +47,36 @@ namespace Jellyfin.Server.Implementations.Tests.Updates
[Fact]
public async Task GetPackages_Valid_Success()
{
IList<PackageInfo> packages = await _installationManager.GetPackages(
PackageInfo[] packages = await _installationManager.GetPackages(
"Jellyfin Stable",
"https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
false);
Assert.Equal(25, packages.Count);
Assert.Equal(25, packages.Length);
}
[Fact]
public async Task FilterPackages_NameOnly_Success()
{
PackageInfo[] packages = await _installationManager.GetPackages(
"Jellyfin Stable",
"https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
false);
packages = _installationManager.FilterPackages(packages, "Anime").ToArray();
Assert.Single(packages);
}
[Fact]
public async Task FilterPackages_GuidOnly_Success()
{
PackageInfo[] packages = await _installationManager.GetPackages(
"Jellyfin Stable",
"https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
false);
packages = _installationManager.FilterPackages(packages, id: new Guid("a4df60c5-6ab4-412a-8f79-2cab93fb2bc5")).ToArray();
Assert.Single(packages);
}
}
}

View File

@ -14,8 +14,6 @@ using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using Xunit;
#pragma warning disable CA5369
namespace Jellyfin.XbmcMetadata.Tests.Parsers
{
public class EpisodeNfoProviderTests

View File

@ -1,6 +1,4 @@
#pragma warning disable CA5369
using System;
using System;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.Audio;

View File

@ -1,6 +1,4 @@
#pragma warning disable CA5369
using System;
using System;
using System.Linq;
using System.Threading;
using MediaBrowser.Common.Configuration;