Merge pull request #3899 from crobibero/plugin-install

Install specific plugin version if requested
This commit is contained in:
Anthony Lavado 2020-09-07 19:39:55 -04:00 committed by GitHub
commit cc6b03296a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 9 deletions

View File

@ -183,7 +183,8 @@ namespace Emby.Server.Implementations.Updates
IEnumerable<PackageInfo> availablePackages, IEnumerable<PackageInfo> availablePackages,
string name = null, string name = null,
Guid guid = default, Guid guid = default,
Version minVersion = null) Version minVersion = null,
Version specificVersion = null)
{ {
var package = FilterPackages(availablePackages, name, guid).FirstOrDefault(); var package = FilterPackages(availablePackages, name, guid).FirstOrDefault();
@ -197,7 +198,11 @@ namespace Emby.Server.Implementations.Updates
var availableVersions = package.versions var availableVersions = package.versions
.Where(x => Version.Parse(x.targetAbi) <= appVer); .Where(x => Version.Parse(x.targetAbi) <= appVer);
if (minVersion != null) if (specificVersion != null)
{
availableVersions = availableVersions.Where(x => new Version(x.version) == specificVersion);
}
else if (minVersion != null)
{ {
availableVersions = availableVersions.Where(x => new Version(x.version) >= minVersion); availableVersions = availableVersions.Where(x => new Version(x.version) >= minVersion);
} }
@ -227,8 +232,8 @@ namespace Emby.Server.Implementations.Updates
{ {
foreach (var plugin in _applicationHost.Plugins) foreach (var plugin in _applicationHost.Plugins)
{ {
var compatibleversions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, plugin.Version); var compatibleVersions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, minVersion: plugin.Version);
var version = compatibleversions.FirstOrDefault(y => y.Version > plugin.Version); var version = compatibleVersions.FirstOrDefault(y => y.Version > plugin.Version);
if (version != null && CompletedInstallations.All(x => x.Guid != version.Guid)) if (version != null && CompletedInstallations.All(x => x.Guid != version.Guid))
{ {
yield return version; yield return version;

View File

@ -49,9 +49,10 @@ namespace Jellyfin.Api.Controllers
{ {
var packages = await _installationManager.GetAvailablePackages().ConfigureAwait(false); var packages = await _installationManager.GetAvailablePackages().ConfigureAwait(false);
var result = _installationManager.FilterPackages( var result = _installationManager.FilterPackages(
packages, packages,
name, name,
string.IsNullOrEmpty(assemblyGuid) ? default : Guid.Parse(assemblyGuid)).FirstOrDefault(); string.IsNullOrEmpty(assemblyGuid) ? default : Guid.Parse(assemblyGuid))
.FirstOrDefault();
return result; return result;
} }
@ -93,7 +94,8 @@ namespace Jellyfin.Api.Controllers
packages, packages,
name, name,
string.IsNullOrEmpty(assemblyGuid) ? Guid.Empty : Guid.Parse(assemblyGuid), string.IsNullOrEmpty(assemblyGuid) ? Guid.Empty : Guid.Parse(assemblyGuid),
string.IsNullOrEmpty(version) ? null : Version.Parse(version)).FirstOrDefault(); specificVersion: string.IsNullOrEmpty(version) ? null : Version.Parse(version))
.FirstOrDefault();
if (package == null) if (package == null)
{ {

View File

@ -73,12 +73,14 @@ namespace MediaBrowser.Common.Updates
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
/// <param name="guid">The guid of the plugin.</param> /// <param name="guid">The guid of the plugin.</param>
/// <param name="minVersion">The minimum required version of the plugin.</param> /// <param name="minVersion">The minimum required version of the plugin.</param>
/// <param name="specificVersion">The specific version of the plugin to install.</param>
/// <returns>All compatible versions ordered from newest to oldest.</returns> /// <returns>All compatible versions ordered from newest to oldest.</returns>
IEnumerable<InstallationInfo> GetCompatibleVersions( IEnumerable<InstallationInfo> GetCompatibleVersions(
IEnumerable<PackageInfo> availablePackages, IEnumerable<PackageInfo> availablePackages,
string name = null, string name = null,
Guid guid = default, Guid guid = default,
Version minVersion = null); Version minVersion = null,
Version specificVersion = null);
/// <summary> /// <summary>
/// Returns the available plugin updates. /// Returns the available plugin updates.