Minor fixes

This commit is contained in:
Bond_009 2021-06-06 18:11:51 +02:00
parent d461e3912a
commit c78457e6d3
14 changed files with 51 additions and 52 deletions

View File

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

View File

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

View File

@ -25,7 +25,7 @@ namespace MediaBrowser.Common.Updates
/// <param name="filterIncompatible">Filter out incompatible plugins.</param> /// <param name="filterIncompatible">Filter out incompatible plugins.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{IReadOnlyList{PackageInfo}}.</returns> /// <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> /// <summary>
/// Gets all available packages that are supported by this version. /// Gets all available packages that are supported by this version.
@ -45,7 +45,7 @@ namespace MediaBrowser.Common.Updates
IEnumerable<PackageInfo> FilterPackages( IEnumerable<PackageInfo> FilterPackages(
IEnumerable<PackageInfo> availablePackages, IEnumerable<PackageInfo> availablePackages,
string? name = null, string? name = null,
Guid? id = default, Guid id = default,
Version? specificVersion = null); Version? specificVersion = null);
/// <summary> /// <summary>
@ -60,7 +60,7 @@ namespace MediaBrowser.Common.Updates
IEnumerable<InstallationInfo> GetCompatibleVersions( IEnumerable<InstallationInfo> GetCompatibleVersions(
IEnumerable<PackageInfo> availablePackages, IEnumerable<PackageInfo> availablePackages,
string? name = null, string? name = null,
Guid? id = default, Guid id = default,
Version? minVersion = null, Version? minVersion = null,
Version? specificVersion = 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> /// <summary>
/// Disable media source display. /// Disable media source display.
@ -11,4 +9,4 @@ namespace MediaBrowser.Controller.Channels
public interface IDisableMediaSourceDisplay public interface IDisableMediaSourceDisplay
{ {
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
using System.Collections.Generic; using System;
using System.IO; using System.IO;
using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -46,12 +47,36 @@ namespace Jellyfin.Server.Implementations.Tests.Updates
[Fact] [Fact]
public async Task GetPackages_Valid_Success() public async Task GetPackages_Valid_Success()
{ {
IList<PackageInfo> packages = await _installationManager.GetPackages( PackageInfo[] packages = await _installationManager.GetPackages(
"Jellyfin Stable", "Jellyfin Stable",
"https://repo.jellyfin.org/releases/plugin/manifest-stable.json", "https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
false); 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 Moq;
using Xunit; using Xunit;
#pragma warning disable CA5369
namespace Jellyfin.XbmcMetadata.Tests.Parsers namespace Jellyfin.XbmcMetadata.Tests.Parsers
{ {
public class EpisodeNfoProviderTests public class EpisodeNfoProviderTests

View File

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

View File

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