mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 11:34:57 +02:00
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
This commit is contained in:
commit
95b2a04fe2
8 changed files with 70 additions and 22 deletions
|
@ -15,7 +15,7 @@ namespace MediaBrowser.Api
|
|||
/// Class GetPackage
|
||||
/// </summary>
|
||||
[Route("/Packages/{Name}", "GET")]
|
||||
[Api(("Gets a package, by name"))]
|
||||
[Api(("Gets a package, by name or assembly guid"))]
|
||||
public class GetPackage : IReturn<PackageInfo>
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -24,6 +24,13 @@ namespace MediaBrowser.Api
|
|||
/// <value>The name.</value>
|
||||
[ApiMember(Name = "Name", Description = "The name of the package", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
[ApiMember(Name = "AssemblyGuid", Description = "The guid of the associated assembly", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string AssemblyGuid { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -76,6 +83,13 @@ namespace MediaBrowser.Api
|
|||
[ApiMember(Name = "Name", Description = "Package name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
[ApiMember(Name = "AssemblyGuid", Description = "Guid of the associated assembly", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||
public string AssemblyGuid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
|
@ -157,7 +171,8 @@ namespace MediaBrowser.Api
|
|||
{
|
||||
var packages = _installationManager.GetAvailablePackages(CancellationToken.None, applicationVersion: _appHost.ApplicationVersion).Result;
|
||||
|
||||
var result = packages.FirstOrDefault(p => p.name.Equals(request.Name, StringComparison.OrdinalIgnoreCase));
|
||||
var result = packages.FirstOrDefault(p => string.Equals(p.guid, request.AssemblyGuid ?? "none", StringComparison.OrdinalIgnoreCase))
|
||||
?? packages.FirstOrDefault(p => p.name.Equals(request.Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -194,8 +209,8 @@ namespace MediaBrowser.Api
|
|||
public void Post(InstallPackage request)
|
||||
{
|
||||
var package = string.IsNullOrEmpty(request.Version) ?
|
||||
_installationManager.GetLatestCompatibleVersion(request.Name, _appHost.ApplicationVersion, request.UpdateClass).Result :
|
||||
_installationManager.GetPackage(request.Name, request.UpdateClass, Version.Parse(request.Version)).Result;
|
||||
_installationManager.GetLatestCompatibleVersion(request.Name, request.AssemblyGuid, _appHost.ApplicationVersion, request.UpdateClass).Result :
|
||||
_installationManager.GetPackage(request.Name, request.AssemblyGuid, request.UpdateClass, Version.Parse(request.Version)).Result;
|
||||
|
||||
if (package == null)
|
||||
{
|
||||
|
|
|
@ -255,14 +255,16 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||
/// Gets the package.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="guid">The assembly guid</param>
|
||||
/// <param name="classification">The classification.</param>
|
||||
/// <param name="version">The version.</param>
|
||||
/// <returns>Task{PackageVersionInfo}.</returns>
|
||||
public async Task<PackageVersionInfo> GetPackage(string name, PackageVersionClass classification, Version version)
|
||||
public async Task<PackageVersionInfo> GetPackage(string name, string guid, PackageVersionClass classification, Version version)
|
||||
{
|
||||
var packages = await GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
var package = packages.FirstOrDefault(p => p.name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
var package = packages.FirstOrDefault(p => string.Equals(p.guid, guid ?? "none", StringComparison.OrdinalIgnoreCase))
|
||||
?? packages.FirstOrDefault(p => p.name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (package == null)
|
||||
{
|
||||
|
@ -276,14 +278,15 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||
/// Gets the latest compatible version.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="guid">The assembly guid if this is a plug-in</param>
|
||||
/// <param name="currentServerVersion">The current server version.</param>
|
||||
/// <param name="classification">The classification.</param>
|
||||
/// <returns>Task{PackageVersionInfo}.</returns>
|
||||
public async Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release)
|
||||
public async Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release)
|
||||
{
|
||||
var packages = await GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
return GetLatestCompatibleVersion(packages, name, currentServerVersion, classification);
|
||||
return GetLatestCompatibleVersion(packages, name, guid, currentServerVersion, classification);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -294,9 +297,10 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||
/// <param name="currentServerVersion">The current server version.</param>
|
||||
/// <param name="classification">The classification.</param>
|
||||
/// <returns>PackageVersionInfo.</returns>
|
||||
public PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release)
|
||||
public PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release)
|
||||
{
|
||||
var package = availablePackages.FirstOrDefault(p => p.name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
var package = availablePackages.FirstOrDefault(p => string.Equals(p.guid, guid ?? "none", StringComparison.OrdinalIgnoreCase))
|
||||
?? availablePackages.FirstOrDefault(p => p.name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (package == null)
|
||||
{
|
||||
|
@ -331,14 +335,14 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||
// Figure out what needs to be installed
|
||||
var packages = plugins.Select(p =>
|
||||
{
|
||||
var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, applicationVersion, p.Configuration.UpdateClass);
|
||||
var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, p.Id.ToString(), applicationVersion, p.Configuration.UpdateClass);
|
||||
|
||||
return latestPluginInfo != null && latestPluginInfo.version != null && latestPluginInfo.version > p.Version ? latestPluginInfo : null;
|
||||
|
||||
}).Where(i => i != null).ToList();
|
||||
|
||||
return packages
|
||||
.Where(p => !string.IsNullOrWhiteSpace(p.sourceUrl) && !CompletedInstallations.Any(i => string.Equals(i.Name, p.name, StringComparison.OrdinalIgnoreCase)));
|
||||
.Where(p => !string.IsNullOrWhiteSpace(p.sourceUrl) && !CompletedInstallations.Any(i => string.Equals(i.AssemblyGuid, p.guid, StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -365,6 +369,7 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Name = package.name,
|
||||
AssemblyGuid = package.guid,
|
||||
UpdateClass = package.classification,
|
||||
Version = package.versionStr
|
||||
};
|
||||
|
@ -471,7 +476,8 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||
if (!string.Equals(extension, ".zip", StringComparison.OrdinalIgnoreCase) && !string.Equals(extension, ".rar", StringComparison.OrdinalIgnoreCase) && !string.Equals(extension, ".7z", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Set last update time if we were installed before
|
||||
var plugin = _applicationHost.Plugins.FirstOrDefault(p => p.Name.Equals(package.name, StringComparison.OrdinalIgnoreCase));
|
||||
var plugin = _applicationHost.Plugins.FirstOrDefault(p => string.Equals(p.Id.ToString(), package.guid, StringComparison.OrdinalIgnoreCase))
|
||||
?? _applicationHost.Plugins.FirstOrDefault(p => p.Name.Equals(package.name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (plugin != null)
|
||||
{
|
||||
|
|
|
@ -63,29 +63,32 @@ namespace MediaBrowser.Common.Updates
|
|||
/// Gets the package.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="guid">The assembly guid</param>
|
||||
/// <param name="classification">The classification.</param>
|
||||
/// <param name="version">The version.</param>
|
||||
/// <returns>Task{PackageVersionInfo}.</returns>
|
||||
Task<PackageVersionInfo> GetPackage(string name, PackageVersionClass classification, Version version);
|
||||
Task<PackageVersionInfo> GetPackage(string name, string guid, PackageVersionClass classification, Version version);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the latest compatible version.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="guid">The assembly guid</param>
|
||||
/// <param name="currentServerVersion">The current server version.</param>
|
||||
/// <param name="classification">The classification.</param>
|
||||
/// <returns>Task{PackageVersionInfo}.</returns>
|
||||
Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release);
|
||||
Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the latest compatible version.
|
||||
/// </summary>
|
||||
/// <param name="availablePackages">The available packages.</param>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="guid">The assembly guid</param>
|
||||
/// <param name="currentServerVersion">The current server version.</param>
|
||||
/// <param name="classification">The classification.</param>
|
||||
/// <returns>PackageVersionInfo.</returns>
|
||||
PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release);
|
||||
PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the available plugin updates.
|
||||
|
|
|
@ -19,6 +19,12 @@ namespace MediaBrowser.Model.Updates
|
|||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the assembly guid.
|
||||
/// </summary>
|
||||
/// <value>The guid of the assembly.</value>
|
||||
public string AssemblyGuid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
|
|
|
@ -104,6 +104,13 @@ namespace MediaBrowser.Model.Updates
|
|||
/// <value>The target system.</value>
|
||||
public PackageTargetSystem targetSystem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The guid of the assembly associated with this package (if a plug-in).
|
||||
/// This is used to identify the proper item for automatic updates.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string guid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether or not this package is registered.
|
||||
/// </summary>
|
||||
|
|
|
@ -15,6 +15,12 @@ namespace MediaBrowser.Model.Updates
|
|||
/// <value>The name.</value>
|
||||
public string name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the guid.
|
||||
/// </summary>
|
||||
/// <value>The guid.</value>
|
||||
public string guid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version STR.
|
||||
/// </summary>
|
||||
|
|
|
@ -683,7 +683,7 @@ namespace MediaBrowser.ServerApplication
|
|||
{
|
||||
var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ApplicationVersion,
|
||||
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, null, ApplicationVersion,
|
||||
ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
||||
|
||||
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
|
||||
|
|
|
@ -730,7 +730,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
/**
|
||||
* Installs or updates a new plugin
|
||||
*/
|
||||
self.installPlugin = function (name, updateClass, version) {
|
||||
self.installPlugin = function (name, guid, updateClass, version) {
|
||||
|
||||
if (!name) {
|
||||
throw new Error("null name");
|
||||
|
@ -741,7 +741,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
}
|
||||
|
||||
var options = {
|
||||
updateClass: updateClass
|
||||
updateClass: updateClass,
|
||||
AssemblyGuid: guid
|
||||
};
|
||||
|
||||
if (version) {
|
||||
|
@ -785,13 +786,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
/**
|
||||
* Gets information about an installable package
|
||||
*/
|
||||
self.getPackageInfo = function (name) {
|
||||
self.getPackageInfo = function (name, guid) {
|
||||
|
||||
if (!name) {
|
||||
throw new Error("null name");
|
||||
}
|
||||
|
||||
var url = self.getUrl("Packages/" + name);
|
||||
var options = {
|
||||
AssemblyGuid: guid
|
||||
};
|
||||
|
||||
var url = self.getUrl("Packages/" + name, options);
|
||||
|
||||
return self.ajax({
|
||||
type: "GET",
|
||||
|
|
Loading…
Reference in a new issue