The Free Software Media System - Server Backend & API
Copy previous plugin settings if they don't exist.
Greenbackd9aaba36ec80
diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.csindex 26a029f712..e7589a0f92 100644--- a/Emby.Server.Implementations/Plugins/PluginManager.cs+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs@@ -274,6 +274,32 @@ namespace Emby.Server.Implementations}}+ private void CopyFiles(string source, string destination, bool overwrite, string searchPattern)+ {+ FileInfo[] files;+ try+ {+ files = new DirectoryInfo(source).GetFiles(searchPattern);+ }+ catch (Exception ex)+ {+ _logger.LogDebug(ex, "Error retrieving file list.");+ return;+ }++ foreach (FileInfo file in files)+ {+ try+ {+ file.CopyTo(Path.Combine(destination, file.Name), overwrite);+ }+ catch (Exception ex)+ {+ _logger.LogDebug(ex, "Error copying file {Name}", file.Name);+ }+ }+ }+/// <summary>/// Changes the status of the other versions of the plugin to "Superceded"./// </summary>@@ -295,6 +321,9 @@ namespace Emby.Server.Implementationsreturn;}+ // migrate settings across from the last active version if they don't exist.+ CopyFiles(predecessor.Path, plugin.Path, false, "*.xml");+if (predecessor.Manifest.Status == PluginStatus.Active && !ChangePluginState(predecessor, PluginStatus.Superceded)){_logger.LogError("Unable to disable version {Version} of {Name}", predecessor.Version, predecessor.Name);diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.csindex a0d6b8f836..5756f8852c 100644--- a/MediaBrowser.Common/Plugins/BasePlugin.cs+++ b/MediaBrowser.Common/Plugins/BasePlugin.cs@@ -166,14 +166,14 @@ namespace MediaBrowser.Common.PluginsassemblyPlugin.SetId(assemblyId);}- // TODO : Simplify this, once migration support is ceased.+ // TODO : Remove this, once migration support is ceased.if (inPluginFolder){var oldConfigFilePath = Path.Combine(ApplicationPaths.PluginConfigurationsPath, ConfigurationFileName);if (!File.Exists(ConfigurationFilePath) && File.Exists(oldConfigFilePath)){- // Migrate settings, as different plugin versions may have different settings.+ // Migrate pre 10.7 settings, as different plugin versions may have different settings.try{File.Copy(oldConfigFilePath, ConfigurationFilePath);