Merge pull request #4254 from BaronGreenback/PluginConfigFix
Fix for #4241: Plugin config initialisation.
This commit is contained in:
commit
42fb04b084
|
@ -821,38 +821,6 @@ namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (plugin is IPluginAssembly assemblyPlugin)
|
|
||||||
{
|
|
||||||
var assembly = plugin.GetType().Assembly;
|
|
||||||
var assemblyName = assembly.GetName();
|
|
||||||
var assemblyFilePath = assembly.Location;
|
|
||||||
|
|
||||||
var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
|
|
||||||
|
|
||||||
assemblyPlugin.SetAttributes(assemblyFilePath, dataFolderPath, assemblyName.Version);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var idAttributes = assembly.GetCustomAttributes(typeof(GuidAttribute), true);
|
|
||||||
if (idAttributes.Length > 0)
|
|
||||||
{
|
|
||||||
var attribute = (GuidAttribute)idAttributes[0];
|
|
||||||
var assemblyId = new Guid(attribute.Value);
|
|
||||||
|
|
||||||
assemblyPlugin.SetId(assemblyId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError(ex, "Error getting plugin Id from {PluginName}.", plugin.GetType().FullName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin is IHasPluginConfiguration hasPluginConfiguration)
|
|
||||||
{
|
|
||||||
hasPluginConfiguration.SetStartupInfo(s => Directory.CreateDirectory(s));
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.RegisterServices(ServiceCollection);
|
plugin.RegisterServices(ServiceCollection);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Model.Plugins;
|
using MediaBrowser.Model.Plugins;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
@ -140,6 +141,30 @@ namespace MediaBrowser.Common.Plugins
|
||||||
{
|
{
|
||||||
ApplicationPaths = applicationPaths;
|
ApplicationPaths = applicationPaths;
|
||||||
XmlSerializer = xmlSerializer;
|
XmlSerializer = xmlSerializer;
|
||||||
|
if (this is IPluginAssembly assemblyPlugin)
|
||||||
|
{
|
||||||
|
var assembly = GetType().Assembly;
|
||||||
|
var assemblyName = assembly.GetName();
|
||||||
|
var assemblyFilePath = assembly.Location;
|
||||||
|
|
||||||
|
var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
|
||||||
|
|
||||||
|
assemblyPlugin.SetAttributes(assemblyFilePath, dataFolderPath, assemblyName.Version);
|
||||||
|
|
||||||
|
var idAttributes = assembly.GetCustomAttributes(typeof(GuidAttribute), true);
|
||||||
|
if (idAttributes.Length > 0)
|
||||||
|
{
|
||||||
|
var attribute = (GuidAttribute)idAttributes[0];
|
||||||
|
var assemblyId = new Guid(attribute.Value);
|
||||||
|
|
||||||
|
assemblyPlugin.SetId(assemblyId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this is IHasPluginConfiguration hasPluginConfiguration)
|
||||||
|
{
|
||||||
|
hasPluginConfiguration.SetStartupInfo(s => Directory.CreateDirectory(s));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user