removed exception

This commit is contained in:
Greenback 2020-12-18 22:17:46 +00:00
parent 9bf970e5c6
commit d34428f2f7

View file

@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.Plugins
// Now load the assemblies.. // Now load the assemblies..
foreach (var plugin in _plugins) foreach (var plugin in _plugins)
{ {
CheckIfStillSuperceded(plugin); UpdatePluginSuperceedStatus(plugin);
if (plugin.IsEnabledAndSupported == false) if (plugin.IsEnabledAndSupported == false)
{ {
@ -134,7 +134,7 @@ namespace Emby.Server.Implementations.Plugins
continue; continue;
} }
CheckIfStillSuperceded(plugin); UpdatePluginSuperceedStatus(plugin);
if (!plugin.IsEnabledAndSupported) if (!plugin.IsEnabledAndSupported)
{ {
continue; continue;
@ -172,7 +172,7 @@ namespace Emby.Server.Implementations.Plugins
// Load the plugin. // Load the plugin.
var plugin = LoadManifest(folder); var plugin = LoadManifest(folder);
// Make sure we haven't already loaded this. // Make sure we haven't already loaded this.
if (plugin == null || _plugins.Any(p => p.Manifest.Equals(plugin.Manifest))) if (_plugins.Any(p => p.Manifest.Equals(plugin.Manifest)))
{ {
return; return;
} }
@ -435,7 +435,7 @@ namespace Emby.Server.Implementations.Plugins
} }
} }
private void CheckIfStillSuperceded(LocalPlugin plugin) private void UpdatePluginSuperceedStatus(LocalPlugin plugin)
{ {
if (plugin.Manifest.Status != PluginStatus.Superceded) if (plugin.Manifest.Status != PluginStatus.Superceded)
{ {
@ -464,7 +464,6 @@ namespace Emby.Server.Implementations.Plugins
{ {
Directory.Delete(plugin.Path, true); Directory.Delete(plugin.Path, true);
_logger.LogDebug("Deleted {Path}", plugin.Path); _logger.LogDebug("Deleted {Path}", plugin.Path);
_plugins.Remove(plugin);
} }
#pragma warning disable CA1031 // Do not catch general exception types #pragma warning disable CA1031 // Do not catch general exception types
catch catch
@ -476,9 +475,7 @@ namespace Emby.Server.Implementations.Plugins
return _plugins.Remove(plugin); return _plugins.Remove(plugin);
} }
private LocalPlugin? LoadManifest(string dir) private LocalPlugin LoadManifest(string dir)
{
try
{ {
Version? version; Version? version;
PluginManifest? manifest = null; PluginManifest? manifest = null;
@ -542,14 +539,6 @@ namespace Emby.Server.Implementations.Plugins
return new LocalPlugin(dir, true, manifest); return new LocalPlugin(dir, true, manifest);
} }
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
_logger.LogError(ex, "Something went wrong!");
return null;
}
}
/// <summary> /// <summary>
/// Gets the list of local plugins. /// Gets the list of local plugins.
@ -566,14 +555,9 @@ namespace Emby.Server.Implementations.Plugins
} }
var directories = Directory.EnumerateDirectories(_pluginsPath, "*.*", SearchOption.TopDirectoryOnly); var directories = Directory.EnumerateDirectories(_pluginsPath, "*.*", SearchOption.TopDirectoryOnly);
LocalPlugin? entry;
foreach (var dir in directories) foreach (var dir in directories)
{ {
entry = LoadManifest(dir); versions.Add(LoadManifest(dir));
if (entry != null)
{
versions.Add(entry);
}
} }
string lastName = string.Empty; string lastName = string.Empty;
@ -582,7 +566,7 @@ namespace Emby.Server.Implementations.Plugins
// The first item will be the latest version. // The first item will be the latest version.
for (int x = versions.Count - 1; x >= 0; x--) for (int x = versions.Count - 1; x >= 0; x--)
{ {
entry = versions[x]; var entry = versions[x];
if (!string.Equals(lastName, entry.Name, StringComparison.OrdinalIgnoreCase)) if (!string.Equals(lastName, entry.Name, StringComparison.OrdinalIgnoreCase))
{ {
entry.DllFiles.AddRange(Directory.EnumerateFiles(entry.Path, "*.dll", SearchOption.AllDirectories)); entry.DllFiles.AddRange(Directory.EnumerateFiles(entry.Path, "*.dll", SearchOption.AllDirectories));