Skip to content

Commit

Permalink
More fixes to file path watching
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Dec 24, 2024
1 parent 857c642 commit 602f85f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ public class FileWatchManager : Singleton<FileWatchManager>

bool IsFlushing;

HashSet<FilePath> filePathsToWatch;

public IReadOnlyCollection<FilePath> CurrentFilePathsWatching => filePathsToWatch;
public FilePath CurrentFilePathWatching { get; private set; }

#endregion

Expand All @@ -54,8 +53,6 @@ public FileWatchManager()

public void EnableWithDirectories(HashSet<FilePath> directories)
{
filePathsToWatch = directories;

FilePath gumProjectFilePath = ProjectManager.Self.GumProjectSave.FullFileName;

char gumProjectDrive = gumProjectFilePath.Standardized[0];
Expand All @@ -78,6 +75,8 @@ public void EnableWithDirectories(HashSet<FilePath> directories)
// Gum standard is to have a trailing slash,
// but FileSystemWatcher expects no trailing slash:
fileSystemWatcher.Path = filePathAsString.Substring(0, filePathAsString.Length - 1);
CurrentFilePathWatching = fileSystemWatcher.Path;

fileSystemWatcher.EnableRaisingEvents = true;
}

Expand Down Expand Up @@ -121,7 +120,7 @@ private void HandleFileSystemChange(FilePath fileName)
if(!wasIgnored)
{
var directoryContainingThis = fileName.GetDirectoryContainingThis();
var isFolderConsidered = filePathsToWatch.Any(item => item == directoryContainingThis || item.IsRootOf(fileName));
var isFolderConsidered = CurrentFilePathWatching == directoryContainingThis || CurrentFilePathWatching.IsRootOf(fileName);

if(!isFolderConsidered)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void HandleElapsed(object sender, ElapsedEventArgs e)
// stuff stuff
var fileWatchManager = FileWatchManager.Self;

if(fileWatchManager.CurrentFilePathsWatching == null)
if(fileWatchManager.CurrentFilePathWatching == null)
{
return;
}
Expand All @@ -109,11 +109,8 @@ private void HandleElapsed(object sender, ElapsedEventArgs e)

if(fileWatchManager.Enabled)
{
filePathsWatchingText = $"File paths watching ({fileWatchManager.CurrentFilePathsWatching?.Count ?? 0}):";
foreach(var item in fileWatchManager.CurrentFilePathsWatching)
{
filePathsWatchingText += $"\n\t{item}";
}
filePathsWatchingText = $"File path watching ({fileWatchManager.CurrentFilePathWatching}):";

viewModel.WatchFolderInformation = filePathsWatchingText;
}
else
Expand Down

0 comments on commit 602f85f

Please sign in to comment.