mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Plugins - Don't load incompatible plugins
This commit is contained in:
1 parent
dc17253518
commit
73a80ef476
4 files changed
+23
-11
No files matched your search
@@ -37,7 +37,7 @@ namespace Artemis.Core.Services
|
||||
/// Loads the plugin located in the provided <paramref name="directory" />
|
||||
/// </summary>
|
||||
/// <param name="directory">The directory where the plugin is located</param>
|
||||
Plugin LoadPlugin(DirectoryInfo directory);
|
||||
Plugin? LoadPlugin(DirectoryInfo directory);
|
||||
|
||||
/// <summary>
|
||||
/// Enables the provided <paramref name="plugin" />
|
||||
@@ -68,7 +68,7 @@ namespace Artemis.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="fileName">The full path to the ZIP file that contains the plugin</param>
|
||||
/// <returns>The resulting plugin</returns>
|
||||
Plugin ImportPlugin(string fileName);
|
||||
Plugin? ImportPlugin(string fileName);
|
||||
|
||||
/// <summary>
|
||||
/// Unloads and permanently removes the provided plugin
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
public Plugin LoadPlugin(DirectoryInfo directory)
|
||||
public Plugin? LoadPlugin(DirectoryInfo directory)
|
||||
{
|
||||
_logger.Verbose("Loading plugin from {directory}", directory.FullName);
|
||||
|
||||
@@ -304,6 +304,9 @@ namespace Artemis.Core.Services
|
||||
// PluginInfo contains the ID which we need to move on
|
||||
PluginInfo pluginInfo = CoreJson.DeserializeObject<PluginInfo>(File.ReadAllText(metadataFile))!;
|
||||
|
||||
if (!pluginInfo.IsCompatible)
|
||||
return null;
|
||||
|
||||
if (pluginInfo.Guid == Constants.CorePluginInfo.Guid)
|
||||
throw new ArtemisPluginException($"Plugin {pluginInfo} cannot use reserved GUID {pluginInfo.Guid}");
|
||||
|
||||
@@ -531,7 +534,7 @@ namespace Artemis.Core.Services
|
||||
OnPluginDisabled(new PluginEventArgs(plugin));
|
||||
}
|
||||
|
||||
public Plugin ImportPlugin(string fileName)
|
||||
public Plugin? ImportPlugin(string fileName)
|
||||
{
|
||||
DirectoryInfo pluginDirectory = new(Constants.PluginsFolder);
|
||||
|
||||
|
||||
Reference in new issue
Block a user