Skip to content

Commit

Permalink
fix file system watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmoore committed Dec 10, 2023
1 parent 9a57d30 commit f4cdf6d
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions SDMetaUI/Services/FileSystemObserver.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using SDMeta;
using System.IO.Abstractions;

namespace SDMetaUI.Services
{
Expand All @@ -17,28 +16,28 @@ public FileSystemObserver(IImageDir configuration)
private readonly IList<string> added = new List<string>();
private readonly IList<string> removed = new List<string>();
private readonly IList<string> removedInAdvanced = new List<string>();
private IEnumerable<IFileSystemWatcher> watchers;
private IEnumerable<FileSystemWatcher> watchers;

private void Start()
{
if (watchers == null)
{
watchers = new List<IFileSystemWatcher>();
watchers = configuration.GetPath().Select(p => GetWatcher(p)).ToList();
}
}

var directoryList = configuration.GetPath();
foreach (var directory in directoryList)
{
var watcher = new FileSystemWatcher(directory);
private FileSystemWatcher GetWatcher(string directory)
{
var watcher = new FileSystemWatcher(directory);

watcher.Created += OnCreated;
watcher.Deleted += OnDeleted;
watcher.Renamed += OnCreated;
watcher.Created += OnCreated;
watcher.Deleted += OnDeleted;
watcher.Renamed += OnCreated;

// watcher.Filter = "*.png";
watcher.IncludeSubdirectories = true;
watcher.EnableRaisingEvents = true;
}
}
// watcher.Filter = "*.png";
watcher.IncludeSubdirectories = true;
watcher.EnableRaisingEvents = true;
return watcher;
}

public void RegisterRemoval(string path)
Expand Down

0 comments on commit f4cdf6d

Please sign in to comment.