The Free Software Media System - Server Backend & API
Keep plugin status after update.
BaronGreenback65f880be323e
diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.csindex 700396c4cf..3a8296455b 100644--- a/Emby.Server.Implementations/Plugins/PluginManager.cs+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs@@ -2,6 +2,7 @@using System;using System.Collections.Generic;+using System.Globalization;using System.IO;using System.Linq;using System.Net.Http;@@ -368,7 +369,7 @@ namespace Emby.Server.Implementations.Plugins}/// <inheritdoc/>- public async Task<bool> GenerateManifest(PackageInfo packageInfo, Version version, string path)+ public async Task<bool> GenerateManifest(PackageInfo packageInfo, Version version, string path, PluginStatus status){if (packageInfo == null){@@ -411,9 +412,9 @@ namespace Emby.Server.Implementations.PluginsOverview = packageInfo.Overview,Owner = packageInfo.Owner,TargetAbi = versionInfo.TargetAbi ?? string.Empty,- Timestamp = string.IsNullOrEmpty(versionInfo.Timestamp) ? DateTime.MinValue : DateTime.Parse(versionInfo.Timestamp),+ Timestamp = string.IsNullOrEmpty(versionInfo.Timestamp) ? DateTime.MinValue : DateTime.Parse(versionInfo.Timestamp, CultureInfo.InvariantCulture),Version = versionInfo.Version,- Status = PluginStatus.Active,+ Status = status == PluginStatus.Disabled ? PluginStatus.Disabled : PluginStatus.Active, // Keep disabled state.AutoUpdate = true,ImagePath = imagePath};diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.csindex fc34f93cdd..e7307aefef 100644--- a/Emby.Server.Implementations/Updates/InstallationManager.cs+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs@@ -22,6 +22,7 @@ using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Events;using MediaBrowser.Controller.Events.Updates;using MediaBrowser.Model.IO;+using MediaBrowser.Model.Plugins;using MediaBrowser.Model.Updates;using Microsoft.Extensions.Logging;@@ -194,7 +195,7 @@ namespace Emby.Server.Implementations.Updatesvar plugin = _pluginManager.GetPlugin(packageGuid, version.VersionNumber);if (plugin != null){- await _pluginManager.GenerateManifest(package, version.VersionNumber, plugin.Path);+ await _pluginManager.GenerateManifest(package, version.VersionNumber, plugin.Path, plugin.Manifest.Status).ConfigureAwait(false);}// Remove versions with a target ABI greater then the current application version.@@ -500,7 +501,8 @@ namespace Emby.Server.Implementations.Updatesvar plugins = _pluginManager.Plugins;foreach (var plugin in plugins){- if (plugin.Manifest?.AutoUpdate == false)+ // Don't auto update when plugin marked not to, or when it's disabled.+ if (plugin.Manifest?.AutoUpdate == false || plugin.Manifest?.Status == MediaBrowser.Model.Plugins.PluginStatus.Disabled){continue;}@@ -515,7 +517,7 @@ namespace Emby.Server.Implementations.Updates}}- private async Task PerformPackageInstallation(InstallationInfo package, CancellationToken cancellationToken)+ private async Task PerformPackageInstallation(InstallationInfo package, PluginStatus status, CancellationToken cancellationToken){var extension = Path.GetExtension(package.SourceUrl);if (!string.Equals(extension, ".zip", StringComparison.OrdinalIgnoreCase))@@ -567,7 +569,7 @@ namespace Emby.Server.Implementations.Updatesstream.Position = 0;_zipClient.ExtractAllFromZip(stream, targetDir, true);- await _pluginManager.GenerateManifest(package.PackageInfo, package.Version, targetDir);+ await _pluginManager.GenerateManifest(package.PackageInfo, package.Version, targetDir, status).ConfigureAwait(false);_pluginManager.ImportPluginFrom(targetDir);}@@ -576,7 +578,7 @@ namespace Emby.Server.Implementations.UpdatesLocalPlugin? plugin = _pluginManager.Plugins.FirstOrDefault(p => p.Id.Equals(package.Id) && p.Version.Equals(package.Version))?? _pluginManager.Plugins.FirstOrDefault(p => p.Name.Equals(package.Name, StringComparison.OrdinalIgnoreCase) && p.Version.Equals(package.Version));- await PerformPackageInstallation(package, cancellationToken).ConfigureAwait(false);+ await PerformPackageInstallation(package, plugin?.Manifest.Status ?? PluginStatus.Active, cancellationToken).ConfigureAwait(false);_logger.LogInformation(plugin == null ? "New plugin installed: {PluginName} {PluginVersion}" : "Plugin updated: {PluginName} {PluginVersion}", package.Name, package.Version);return plugin != null;diff --git a/MediaBrowser.Common/Plugins/IPluginManager.cs b/MediaBrowser.Common/Plugins/IPluginManager.csindex f9a8fb6f7a..0e2e814cb0 100644--- a/MediaBrowser.Common/Plugins/IPluginManager.cs+++ b/MediaBrowser.Common/Plugins/IPluginManager.cs@@ -4,6 +4,7 @@ using System;using System.Collections.Generic;using System.Reflection;using System.Threading.Tasks;+using MediaBrowser.Model.Plugins;using MediaBrowser.Model.Updates;using Microsoft.Extensions.DependencyInjection;@@ -51,8 +52,9 @@ namespace MediaBrowser.Common.Plugins/// <param name="packageInfo">The <see cref="PackageInfo"/> used to generate a manifest.</param>/// <param name="version">Version to be installed.</param>/// <param name="path">The path where to save the manifest.</param>+ /// <param name="status">Initial status of the plugin.</param>/// <returns>True if successful.</returns>- Task<bool> GenerateManifest(PackageInfo packageInfo, Version version, string path);+ Task<bool> GenerateManifest(PackageInfo packageInfo, Version version, string path, PluginStatus status);/// <summary>/// Imports plugin details from a folder.