Remove code for pre-installed plugins
This commit is contained in:
parent
ee89236fe8
commit
1a3543e5a5
|
@ -1564,7 +1564,7 @@ namespace Emby.Server.Implementations
|
|||
/// <returns>IEnumerable{Assembly}.</returns>
|
||||
protected List<Tuple<Assembly, string>> GetComposablePartAssemblies()
|
||||
{
|
||||
var list = GetPluginAssemblies();
|
||||
var list = GetPluginAssemblies(ApplicationPaths.PluginsPath);
|
||||
|
||||
// Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
|
||||
// This will prevent the .dll file from getting locked, and allow us to replace it when needed
|
||||
|
@ -1615,79 +1615,6 @@ namespace Emby.Server.Implementations
|
|||
|
||||
protected abstract IEnumerable<Assembly> GetAssembliesWithPartsInternal();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin assemblies.
|
||||
/// </summary>
|
||||
/// <returns>IEnumerable{Assembly}.</returns>
|
||||
private List<Tuple<Assembly, string>> GetPluginAssemblies()
|
||||
{
|
||||
// Copy pre-installed plugins
|
||||
var sourcePath = Path.Combine(ApplicationPaths.ApplicationResourcesPath, "plugins");
|
||||
CopyPlugins(sourcePath, ApplicationPaths.PluginsPath);
|
||||
|
||||
return GetPluginAssemblies(ApplicationPaths.PluginsPath);
|
||||
}
|
||||
|
||||
private void CopyPlugins(string source, string target)
|
||||
{
|
||||
List<string> files;
|
||||
|
||||
try
|
||||
{
|
||||
files = Directory.EnumerateFiles(source, "*.dll", SearchOption.TopDirectoryOnly)
|
||||
.ToList();
|
||||
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (files.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var sourceFile in files)
|
||||
{
|
||||
var filename = Path.GetFileName(sourceFile);
|
||||
var targetFile = Path.Combine(target, filename);
|
||||
|
||||
var targetFileExists = File.Exists(targetFile);
|
||||
|
||||
if (!targetFileExists && ServerConfigurationManager.Configuration.UninstalledPlugins.Contains(filename, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (targetFileExists && GetDllVersion(targetFile) >= GetDllVersion(sourceFile))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(target);
|
||||
File.Copy(sourceFile, targetFile, true);
|
||||
}
|
||||
}
|
||||
|
||||
private Version GetDllVersion(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = Version.Parse(FileVersionInfo.GetVersionInfo(path).FileVersion);
|
||||
|
||||
Logger.LogInformation("File {Path} has version {Version}", path, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error getting version number from {Path}", path);
|
||||
|
||||
return new Version(1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Tuple<Assembly, string>> GetPluginAssemblies(string path)
|
||||
{
|
||||
try
|
||||
|
|
Loading…
Reference in New Issue
Block a user