Changes as required.

This commit is contained in:
Greenback
2020-12-18 09:04:40 +00:00
parent 4153551dfc
commit 5a3efc5266
3 changed files with 42 additions and 104 deletions

View File

@@ -134,25 +134,11 @@ namespace MediaBrowser.Common.Plugins
var assemblyName = assembly.GetName();
var assemblyFilePath = assembly.Location;
// Find out the plugin folder.
bool inPluginFolder = assemblyFilePath.StartsWith(ApplicationPaths.PluginsPath, StringComparison.OrdinalIgnoreCase);
string path, dataFolderPath;
var configurationFileName = Path.ChangeExtension(Path.GetFileName(assemblyFilePath), ".xml");
if (inPluginFolder)
var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
if (!Directory.Exists(dataFolderPath))
{
// Normal plugin.
path = assemblyFilePath.Substring(ApplicationPaths.PluginsPath.Length).Split('\\', StringSplitOptions.RemoveEmptyEntries)[0];
dataFolderPath = Path.Combine(
Path.Combine(ApplicationPaths.PluginsPath, path),
configurationFileName);
ConfigurationFilePath = dataFolderPath;
}
else
{
// Provider
dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
ConfigurationFilePath = Path.Combine(ApplicationPaths.PluginConfigurationsPath, configurationFileName);
// Try again with the version number appended to the folder name.
dataFolderPath = dataFolderPath + "_" + Version.ToString();
}
assemblyPlugin.SetAttributes(assemblyFilePath, dataFolderPath, assemblyName.Version);
@@ -165,25 +151,6 @@ namespace MediaBrowser.Common.Plugins
assemblyPlugin.SetId(assemblyId);
}
// 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 pre 10.7 settings, as different plugin versions may have different settings.
try
{
File.Copy(oldConfigFilePath, ConfigurationFilePath);
}
catch
{
// Unable to migrate settings.
}
}
}
}
if (this is IHasPluginConfiguration hasPluginConfiguration)