diff options
| author | Bond-009 <bond.009@outlook.com> | 2020-06-22 15:23:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-22 15:23:35 +0200 |
| commit | 464066f362a475aac46ce8162360d8d2cbe86b15 (patch) | |
| tree | 2e56a5e8585714de8f71d989c436a0fa4226a7b2 | |
| parent | a3bc82727a0213c8deb018fe8288e0ff10ef16b3 (diff) | |
| parent | 0bab57ebbcbd39d5479e3df6b37bd41b340640e5 (diff) | |
Merge pull request #3411 from neilsb/system-plugin-removal
Prevent system plugins from being uninstalled
| -rw-r--r-- | Emby.Server.Implementations/Updates/InstallationManager.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Common/Plugins/BasePlugin.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Common/Plugins/IPlugin.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Model/Plugins/PluginInfo.cs | 6 |
4 files changed, 26 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index b1bab8cdd2..4eed79c4ce 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -406,6 +406,12 @@ namespace Emby.Server.Implementations.Updates /// <param name="plugin">The plugin.</param> public void UninstallPlugin(IPlugin plugin) { + if (!plugin.CanUninstall) + { + _logger.LogWarning("Attempt to delete non removable plugin {0}, ignoring request", plugin.Name); + return; + } + plugin.OnUninstalling(); // Remove it the quick way for now diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs index 9e4a360c38..f10a1918f7 100644 --- a/MediaBrowser.Common/Plugins/BasePlugin.cs +++ b/MediaBrowser.Common/Plugins/BasePlugin.cs @@ -2,6 +2,7 @@ using System; using System.IO; +using System.Reflection; using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Serialization; @@ -50,6 +51,12 @@ namespace MediaBrowser.Common.Plugins public string DataFolderPath { get; private set; } /// <summary> + /// Gets a value indicating whether the plugin can be uninstalled. + /// </summary> + public bool CanUninstall => !Path.GetDirectoryName(AssemblyFilePath) + .Equals(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), StringComparison.InvariantCulture); + + /// <summary> /// Gets the plugin info. /// </summary> /// <returns>PluginInfo.</returns> @@ -60,7 +67,8 @@ namespace MediaBrowser.Common.Plugins Name = Name, Version = Version.ToString(), Description = Description, - Id = Id.ToString() + Id = Id.ToString(), + CanUninstall = CanUninstall }; return info; diff --git a/MediaBrowser.Common/Plugins/IPlugin.cs b/MediaBrowser.Common/Plugins/IPlugin.cs index d348209613..7bd37d2106 100644 --- a/MediaBrowser.Common/Plugins/IPlugin.cs +++ b/MediaBrowser.Common/Plugins/IPlugin.cs @@ -41,6 +41,11 @@ namespace MediaBrowser.Common.Plugins string AssemblyFilePath { get; } /// <summary> + /// Gets a value indicating whether the plugin can be uninstalled. + /// </summary> + bool CanUninstall { get; } + + /// <summary> /// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed. /// </summary> /// <value>The data folder path.</value> diff --git a/MediaBrowser.Model/Plugins/PluginInfo.cs b/MediaBrowser.Model/Plugins/PluginInfo.cs index c13f1a89f1..dd215192f9 100644 --- a/MediaBrowser.Model/Plugins/PluginInfo.cs +++ b/MediaBrowser.Model/Plugins/PluginInfo.cs @@ -35,6 +35,12 @@ namespace MediaBrowser.Model.Plugins /// </summary> /// <value>The unique id.</value> public string Id { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether the plugin can be uninstalled. + /// </summary> + public bool CanUninstall { get; set; } + /// <summary> /// Gets or sets the image URL. /// </summary> |
