From 1c7c71075af5f87a00047a56e3cef80fc9791828 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 22 Sep 2013 14:21:55 -0400 Subject: pass current server version into installation manager to get update list --- .../Updates/InstallationManager.cs | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Updates/InstallationManager.cs') diff --git a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs index 732a10893..e1757afd5 100644 --- a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs +++ b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs @@ -225,9 +225,9 @@ namespace MediaBrowser.Common.Implementations.Updates /// Determines whether [is package version up to date] [the specified package version info]. /// /// The package version info. - /// The application version. + /// The current server version. /// true if [is package version up to date] [the specified package version info]; otherwise, false. - private bool IsPackageVersionUpToDate(PackageVersionInfo packageVersionInfo, Version applicationVersion) + private bool IsPackageVersionUpToDate(PackageVersionInfo packageVersionInfo, Version currentServerVersion) { if (string.IsNullOrEmpty(packageVersionInfo.requiredVersionStr)) { @@ -236,7 +236,7 @@ namespace MediaBrowser.Common.Implementations.Updates Version requiredVersion; - return Version.TryParse(packageVersionInfo.requiredVersionStr, out requiredVersion) && applicationVersion >= requiredVersion; + return Version.TryParse(packageVersionInfo.requiredVersionStr, out requiredVersion) && currentServerVersion >= requiredVersion; } /// @@ -264,13 +264,14 @@ namespace MediaBrowser.Common.Implementations.Updates /// Gets the latest compatible version. /// /// The name. + /// The current server version. /// The classification. /// Task{PackageVersionInfo}. - public async Task GetLatestCompatibleVersion(string name, PackageVersionClass classification = PackageVersionClass.Release) + public async Task GetLatestCompatibleVersion(string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release) { var packages = await GetAvailablePackages(CancellationToken.None).ConfigureAwait(false); - return GetLatestCompatibleVersion(packages, name, classification); + return GetLatestCompatibleVersion(packages, name, currentServerVersion, classification); } /// @@ -278,9 +279,10 @@ namespace MediaBrowser.Common.Implementations.Updates /// /// The available packages. /// The name. + /// The current server version. /// The classification. /// PackageVersionInfo. - public PackageVersionInfo GetLatestCompatibleVersion(IEnumerable availablePackages, string name, PackageVersionClass classification = PackageVersionClass.Release) + public PackageVersionInfo GetLatestCompatibleVersion(IEnumerable availablePackages, string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release) { var package = availablePackages.FirstOrDefault(p => p.name.Equals(name, StringComparison.OrdinalIgnoreCase)); @@ -291,23 +293,20 @@ namespace MediaBrowser.Common.Implementations.Updates return package.versions .OrderByDescending(v => v.version) - .FirstOrDefault(v => v.classification <= classification && IsPackageVersionUpToDate(v, _applicationHost.ApplicationVersion)); + .FirstOrDefault(v => v.classification <= classification && IsPackageVersionUpToDate(v, currentServerVersion)); } /// /// Gets the available plugin updates. /// + /// The current server version. /// if set to true [with auto update enabled]. /// The cancellation token. /// Task{IEnumerable{PackageVersionInfo}}. - public async Task> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken) + public async Task> GetAvailablePluginUpdates(Version currentServerVersion, bool withAutoUpdateEnabled, CancellationToken cancellationToken) { var catalog = await GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false); - return FilterCatalog(catalog, withAutoUpdateEnabled); - } - protected IEnumerable FilterCatalog(IEnumerable catalog, bool withAutoUpdateEnabled) - { var plugins = _applicationHost.Plugins.ToList(); if (withAutoUpdateEnabled) @@ -320,7 +319,7 @@ namespace MediaBrowser.Common.Implementations.Updates // Figure out what needs to be installed var packages = plugins.Select(p => { - var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, p.Configuration.UpdateClass); + var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, currentServerVersion, p.Configuration.UpdateClass); return latestPluginInfo != null && latestPluginInfo.version != null && latestPluginInfo.version > p.Version ? latestPluginInfo : null; -- cgit v1.2.3