Do not resolve bundled plugins via repos
This commit is contained in:
@@ -3,7 +3,9 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Common.Api;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Common.Updates;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Updates;
|
||||
@@ -23,16 +25,22 @@ public class PackageController : BaseJellyfinApiController
|
||||
{
|
||||
private readonly IInstallationManager _installationManager;
|
||||
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly IPluginManager _pluginManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PackageController"/> class.
|
||||
/// </summary>
|
||||
/// <param name="installationManager">Instance of the <see cref="IInstallationManager"/> interface.</param>
|
||||
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
|
||||
public PackageController(IInstallationManager installationManager, IServerConfigurationManager serverConfigurationManager)
|
||||
/// <param name="pluginManager">Instance of the <see cref="IPluginManager"/> interface.</param>
|
||||
public PackageController(
|
||||
IInstallationManager installationManager,
|
||||
IServerConfigurationManager serverConfigurationManager,
|
||||
IPluginManager pluginManager)
|
||||
{
|
||||
_installationManager = installationManager;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_pluginManager = pluginManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -48,6 +56,13 @@ public class PackageController : BaseJellyfinApiController
|
||||
[FromRoute, Required] string name,
|
||||
[FromQuery] Guid? assemblyGuid)
|
||||
{
|
||||
// Plugins bundled with the server are not published to any repository, so querying
|
||||
// the configured repositories for them can only ever fail, and does so slowly.
|
||||
if (IsBundledPlugin(name, assemblyGuid))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var packages = await _installationManager.GetAvailablePackages().ConfigureAwait(false);
|
||||
var result = _installationManager.FilterPackages(
|
||||
packages,
|
||||
@@ -96,6 +111,11 @@ public class PackageController : BaseJellyfinApiController
|
||||
[FromQuery] string? version,
|
||||
[FromQuery] string? repositoryUrl)
|
||||
{
|
||||
if (IsBundledPlugin(name, assemblyGuid))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var packages = await _installationManager.GetAvailablePackages().ConfigureAwait(false);
|
||||
if (!string.IsNullOrEmpty(repositoryUrl))
|
||||
{
|
||||
@@ -161,4 +181,13 @@ public class PackageController : BaseJellyfinApiController
|
||||
_serverConfigurationManager.SaveConfiguration();
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
private bool IsBundledPlugin(string name, Guid? assemblyGuid)
|
||||
{
|
||||
var plugin = assemblyGuid is Guid id && !id.IsEmpty()
|
||||
? _pluginManager.GetPlugin(id)
|
||||
: _pluginManager.Plugins.FirstOrDefault(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return plugin?.Instance?.CanUninstall == false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user