aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/PackageService.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2019-12-06 22:06:16 +0100
committerBond_009 <bond.009@outlook.com>2019-12-06 22:06:16 +0100
commitec70f3ac75dad10b076a475bbec6d71ded9881a6 (patch)
treeb003e56cec480d397f2e589a1eaf83c3b1ca462b /MediaBrowser.Api/PackageService.cs
parent6f283d80dc00fe63b59dfb7a134528f295615da7 (diff)
Fix plugin installation and correct api behaviour
The `/Packages/{Name}` endpoint would return a package that had either the corrent name or the correct guid. In reality it shoud check if both are correct.
Diffstat (limited to 'MediaBrowser.Api/PackageService.cs')
-rw-r--r--MediaBrowser.Api/PackageService.cs12
1 files changed, 6 insertions, 6 deletions
diff --git a/MediaBrowser.Api/PackageService.cs b/MediaBrowser.Api/PackageService.cs
index 1e5a93210..325acfb7b 100644
--- a/MediaBrowser.Api/PackageService.cs
+++ b/MediaBrowser.Api/PackageService.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
-using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common;
using MediaBrowser.Common.Extensions;
@@ -133,10 +132,11 @@ namespace MediaBrowser.Api
/// <returns>System.Object.</returns>
public object Get(GetPackage request)
{
- var packages = _installationManager.GetAvailablePackages().Result;
-
- var result = packages.FirstOrDefault(p => string.Equals(p.guid, request.AssemblyGuid ?? "none", StringComparison.OrdinalIgnoreCase))
- ?? packages.FirstOrDefault(p => p.name.Equals(request.Name, StringComparison.OrdinalIgnoreCase));
+ var packages = _installationManager.GetAvailablePackages().GetAwaiter().GetResult();
+ var result = _installationManager.FilterPackages(
+ packages,
+ request.Name,
+ string.IsNullOrEmpty(request.AssemblyGuid) ? default : Guid.Parse(request.AssemblyGuid)).FirstOrDefault();
return ToOptimizedResult(result);
}
@@ -181,7 +181,7 @@ namespace MediaBrowser.Api
var package = _installationManager.GetCompatibleVersions(
packages,
request.Name,
- new Guid(request.AssemblyGuid),
+ string.IsNullOrEmpty(request.AssemblyGuid) ? Guid.Empty : Guid.Parse(request.AssemblyGuid),
string.IsNullOrEmpty(request.Version) ? null : Version.Parse(request.Version),
request.UpdateClass).FirstOrDefault();