mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Changes as required.
This commit is contained in:
parent
4153551dfc
commit
5a3efc5266
@ -35,6 +35,7 @@ using Emby.Server.Implementations.LiveTv;
|
|||||||
using Emby.Server.Implementations.Localization;
|
using Emby.Server.Implementations.Localization;
|
||||||
using Emby.Server.Implementations.Net;
|
using Emby.Server.Implementations.Net;
|
||||||
using Emby.Server.Implementations.Playlists;
|
using Emby.Server.Implementations.Playlists;
|
||||||
|
using Emby.Server.Implementations.Plugins;
|
||||||
using Emby.Server.Implementations.QuickConnect;
|
using Emby.Server.Implementations.QuickConnect;
|
||||||
using Emby.Server.Implementations.ScheduledTasks;
|
using Emby.Server.Implementations.ScheduledTasks;
|
||||||
using Emby.Server.Implementations.Security;
|
using Emby.Server.Implementations.Security;
|
||||||
@ -281,7 +282,7 @@ namespace Emby.Server.Implementations
|
|||||||
ApplicationUserAgent = Name.Replace(' ', '-') + "/" + ApplicationVersionString;
|
ApplicationUserAgent = Name.Replace(' ', '-') + "/" + ApplicationVersionString;
|
||||||
|
|
||||||
_pluginManager = new PluginManager(
|
_pluginManager = new PluginManager(
|
||||||
LoggerFactory,
|
LoggerFactory.CreateLogger<PluginManager>(),
|
||||||
this,
|
this,
|
||||||
ServerConfigurationManager.Configuration,
|
ServerConfigurationManager.Configuration,
|
||||||
ApplicationPaths.PluginsPath,
|
ApplicationPaths.PluginsPath,
|
||||||
|
@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.Plugins
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PluginManager"/> class.
|
/// Initializes a new instance of the <see cref="PluginManager"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="loggerfactory">The <see cref="ILoggerFactory"/>.</param>
|
/// <param name="logger">The <see cref="ILogger"/>.</param>
|
||||||
/// <param name="appHost">The <see cref="IApplicationHost"/>.</param>
|
/// <param name="appHost">The <see cref="IApplicationHost"/>.</param>
|
||||||
/// <param name="config">The <see cref="ServerConfiguration"/>.</param>
|
/// <param name="config">The <see cref="ServerConfiguration"/>.</param>
|
||||||
/// <param name="pluginsPath">The plugin path.</param>
|
/// <param name="pluginsPath">The plugin path.</param>
|
||||||
@ -49,13 +49,12 @@ namespace Emby.Server.Implementations.Plugins
|
|||||||
string imagesPath,
|
string imagesPath,
|
||||||
Version appVersion)
|
Version appVersion)
|
||||||
{
|
{
|
||||||
_logger = loggerfactory.CreateLogger<PluginManager>();
|
_logger = _logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
_pluginsPath = pluginsPath;
|
_pluginsPath = pluginsPath;
|
||||||
_appVersion = appVersion ?? throw new ArgumentNullException(nameof(appVersion));
|
_appVersion = appVersion ?? throw new ArgumentNullException(nameof(appVersion));
|
||||||
_jsonOptions = JsonDefaults.GetCamelCaseOptions();
|
_jsonOptions = JsonDefaults.GetOptions();
|
||||||
_config = config;
|
_config = config;
|
||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
_imagesPath = imagesPath;
|
|
||||||
_nextVersion = new Version(_appVersion.Major, _appVersion.Minor + 2, _appVersion.Build, _appVersion.Revision);
|
_nextVersion = new Version(_appVersion.Major, _appVersion.Minor + 2, _appVersion.Build, _appVersion.Revision);
|
||||||
_minimumVersion = new Version(0, 0, 0, 1);
|
_minimumVersion = new Version(0, 0, 0, 1);
|
||||||
_plugins = Directory.Exists(_pluginsPath) ? DiscoverPlugins().ToList() : new List<LocalPlugin>();
|
_plugins = Directory.Exists(_pluginsPath) ? DiscoverPlugins().ToList() : new List<LocalPlugin>();
|
||||||
@ -273,62 +272,6 @@ namespace Emby.Server.Implementations.Plugins
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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>
|
|
||||||
/// <param name="plugin">The <see cref="LocalPlugin"/> that's master.</param>
|
|
||||||
private void UpdateSuccessors(LocalPlugin plugin)
|
|
||||||
{
|
|
||||||
// This value is memory only - so that the web will show restart required.
|
|
||||||
plugin.Manifest.Status = PluginStatus.Restart;
|
|
||||||
|
|
||||||
// Detect whether there is another version of this plugin that needs disabling.
|
|
||||||
var predecessor = _plugins.OrderByDescending(p => p.Version)
|
|
||||||
.FirstOrDefault(
|
|
||||||
p => p.Id.Equals(plugin.Id)
|
|
||||||
&& p.IsEnabledAndSupported
|
|
||||||
&& p.Version != plugin.Version);
|
|
||||||
|
|
||||||
if (predecessor == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disable the plugin.
|
/// Disable the plugin.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -429,19 +372,19 @@ namespace Emby.Server.Implementations.Plugins
|
|||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
{
|
{
|
||||||
// Create a dummy record for the providers.
|
// Create a dummy record for the providers.
|
||||||
|
// TODO: remove this code, if all provided have been released as separate plugins.
|
||||||
plugin = new LocalPlugin(
|
plugin = new LocalPlugin(
|
||||||
pInstance.AssemblyFilePath,
|
instance.AssemblyFilePath,
|
||||||
true,
|
true,
|
||||||
new PluginManifest
|
new PluginManifest
|
||||||
{
|
{
|
||||||
Guid = pInstance.Id,
|
Guid = instance.Id,
|
||||||
Status = PluginStatus.Active,
|
Status = PluginStatus.Active,
|
||||||
Name = pInstance.Name,
|
Name = instance.Name,
|
||||||
Version = pInstance.Version.ToString(),
|
Version = instance.Version.ToString()
|
||||||
MaxAbi = _nextVersion.ToString()
|
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
Instance = pInstance
|
Instance = instance
|
||||||
};
|
};
|
||||||
|
|
||||||
_plugins.Add(plugin);
|
_plugins.Add(plugin);
|
||||||
@ -707,5 +650,32 @@ namespace Emby.Server.Implementations.Plugins
|
|||||||
// Only want plugin folders which have files.
|
// Only want plugin folders which have files.
|
||||||
return versions.Where(p => p.DllFiles.Count != 0);
|
return versions.Where(p => p.DllFiles.Count != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the status of the other versions of the plugin to "Superceded".
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plugin">The <see cref="LocalPlugin"/> that's master.</param>
|
||||||
|
private void UpdateSuccessors(LocalPlugin plugin)
|
||||||
|
{
|
||||||
|
// This value is memory only - so that the web will show restart required.
|
||||||
|
plugin.Manifest.Status = PluginStatus.Restart;
|
||||||
|
|
||||||
|
// Detect whether there is another version of this plugin that needs disabling.
|
||||||
|
var predecessor = _plugins.OrderByDescending(p => p.Version)
|
||||||
|
.FirstOrDefault(
|
||||||
|
p => p.Id.Equals(plugin.Id)
|
||||||
|
&& p.IsEnabledAndSupported
|
||||||
|
&& p.Version != plugin.Version);
|
||||||
|
|
||||||
|
if (predecessor == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (predecessor.Manifest.Status == PluginStatus.Active && !ChangePluginState(predecessor, PluginStatus.Superceded))
|
||||||
|
{
|
||||||
|
_logger.LogError("Unable to disable version {Version} of {Name}", predecessor.Version, predecessor.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,25 +134,11 @@ namespace MediaBrowser.Common.Plugins
|
|||||||
var assemblyName = assembly.GetName();
|
var assemblyName = assembly.GetName();
|
||||||
var assemblyFilePath = assembly.Location;
|
var assemblyFilePath = assembly.Location;
|
||||||
|
|
||||||
// Find out the plugin folder.
|
var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
|
||||||
bool inPluginFolder = assemblyFilePath.StartsWith(ApplicationPaths.PluginsPath, StringComparison.OrdinalIgnoreCase);
|
if (!Directory.Exists(dataFolderPath))
|
||||||
string path, dataFolderPath;
|
|
||||||
|
|
||||||
var configurationFileName = Path.ChangeExtension(Path.GetFileName(assemblyFilePath), ".xml");
|
|
||||||
if (inPluginFolder)
|
|
||||||
{
|
{
|
||||||
// Normal plugin.
|
// Try again with the version number appended to the folder name.
|
||||||
path = assemblyFilePath.Substring(ApplicationPaths.PluginsPath.Length).Split('\\', StringSplitOptions.RemoveEmptyEntries)[0];
|
dataFolderPath = dataFolderPath + "_" + Version.ToString();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assemblyPlugin.SetAttributes(assemblyFilePath, dataFolderPath, assemblyName.Version);
|
assemblyPlugin.SetAttributes(assemblyFilePath, dataFolderPath, assemblyName.Version);
|
||||||
@ -165,25 +151,6 @@ namespace MediaBrowser.Common.Plugins
|
|||||||
|
|
||||||
assemblyPlugin.SetId(assemblyId);
|
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)
|
if (this is IHasPluginConfiguration hasPluginConfiguration)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user