diff --git a/src/Artemis.Core/Plugins/PluginInfo.cs b/src/Artemis.Core/Plugins/PluginInfo.cs
index e8c3f5d50..1eebd03c6 100644
--- a/src/Artemis.Core/Plugins/PluginInfo.cs
+++ b/src/Artemis.Core/Plugins/PluginInfo.cs
@@ -28,6 +28,7 @@ public class PluginInfo : CorePropertyChanged, IPrerequisitesSubject
private string _version = null!;
private Uri? _website;
private Uri? _helpPage;
+ private bool _hotReloadSupported;
internal PluginInfo()
{
@@ -156,6 +157,17 @@ public class PluginInfo : CorePropertyChanged, IPrerequisitesSubject
internal set => SetAndNotify(ref _requiresAdmin, value);
}
+ ///
+ /// Gets or sets a boolean indicating whether hot reloading this plugin is supported
+ ///
+ [DefaultValue(true)]
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
+ public bool HotReloadSupported
+ {
+ get => _hotReloadSupported;
+ set => SetAndNotify(ref _hotReloadSupported, value);
+ }
+
///
/// Gets
///
diff --git a/src/Artemis.Core/Services/PluginManagementService.cs b/src/Artemis.Core/Services/PluginManagementService.cs
index 1e24feb47..fb304baf5 100644
--- a/src/Artemis.Core/Services/PluginManagementService.cs
+++ b/src/Artemis.Core/Services/PluginManagementService.cs
@@ -938,7 +938,7 @@ internal class PluginManagementService : IPluginManagementService
_hotReloadWatcher.IncludeSubdirectories = true;
_hotReloadWatcher.EnableRaisingEvents = true;
}
-
+
private void FileSystemWatcherOnError(object sender, ErrorEventArgs e)
{
_logger.Error(e.GetException(), "File system watcher error");
@@ -952,38 +952,38 @@ internal class PluginManagementService : IPluginManagementService
_logger.Warning("Plugin change detected, but could not get plugin directory. {fullPath}", e.FullPath);
return;
}
-
+
DirectoryInfo pluginDirectory = new(pluginPath);
Plugin? plugin = GetPluginByDirectory(pluginDirectory);
-
+
if (plugin == null)
{
_logger.Warning("Plugin change detected, but could not find plugin. {fullPath}", e.FullPath);
return;
}
-
- _logger.Information("Plugin change detected, reloading. {pluginName}", plugin.Info.Name);
- bool wasEnabled = plugin.IsEnabled;
-
- UnloadPlugin(plugin);
-
- Thread.Sleep(500);
-
- Plugin? loadedPlugin = LoadPlugin(pluginDirectory);
-
- if (loadedPlugin == null)
+
+ if (!plugin.Info.HotReloadSupported)
{
+ _logger.Information("Plugin change detected, but hot reload not supported. {pluginName}", plugin.Info.Name);
return;
}
-
+
+ _logger.Information("Plugin change detected, reloading. {pluginName}", plugin.Info.Name);
+ bool wasEnabled = plugin.IsEnabled;
+
+ UnloadPlugin(plugin);
+ Thread.Sleep(500);
+ Plugin? loadedPlugin = LoadPlugin(pluginDirectory);
+
+ if (loadedPlugin == null)
+ return;
+
if (wasEnabled)
- {
EnablePlugin(loadedPlugin, true, false);
- }
-
+
_logger.Information("Plugin reloaded. {fullPath}", e.FullPath);
}
-
+
#endregion
}