Skip to content

Commit

Permalink
Plugin file watcher only reminds user to restart node (#2823)
Browse files Browse the repository at this point in the history
* init

* deleted
  • Loading branch information
Ashuaidehao authored Oct 24, 2022
1 parent fcbf479 commit 77ee2cc
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/Neo/Plugins/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ static Plugin()
{
EnableRaisingEvents = true,
IncludeSubdirectories = true,
NotifyFilter = NotifyFilters.CreationTime | NotifyFilters.LastWrite | NotifyFilters.Size,
NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.CreationTime | NotifyFilters.LastWrite | NotifyFilters.Size,
};
configWatcher.Changed += ConfigWatcher_Changed;
configWatcher.Created += ConfigWatcher_Changed;
configWatcher.Renamed += ConfigWatcher_Changed;
configWatcher.Deleted += ConfigWatcher_Changed;
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}

Expand All @@ -102,20 +104,8 @@ private static void ConfigWatcher_Changed(object sender, FileSystemEventArgs e)
switch (GetExtension(e.Name))
{
case ".json":
try
{
Plugins.FirstOrDefault(p => p.ConfigFile == e.FullPath)?.Configure();
}
catch (FormatException) { }
break;
case ".dll":
if (e.ChangeType != WatcherChangeTypes.Created) return;
if (GetDirectoryName(GetDirectoryName(e.FullPath)) != PluginsDirectory) return;
try
{
LoadPlugin(Assembly.Load(File.ReadAllBytes(e.FullPath)));
}
catch { }
Utility.Log(nameof(Plugin), LogLevel.Warning, $"File {e.Name} is {e.ChangeType}, please restart node.");
break;
}
}
Expand Down

0 comments on commit 77ee2cc

Please sign in to comment.