mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-23 03:39:35 -10:00
Fixing dotnet/corefx#2279 to make the Linux FSW ignore root folder changes
Commit migrated from https://github.com/dotnet/corefx/commit/777e88a068c9e7509fd56bfcce20fbfe52f687f7
This commit is contained in:
1 parent
080287c216
commit
ea00cd6975
2 files changed
+25
No files matched your search
@@ -572,6 +572,13 @@ namespace System.IO
|
||||
expandedName = associatedDirectoryEntry.GetPath(true, nextEvent.name);
|
||||
}
|
||||
|
||||
// To match Windows, ignore all changes that happen on the root folder itself
|
||||
if (string.IsNullOrEmpty(expandedName))
|
||||
{
|
||||
watcher = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine whether the affected object is a directory (rather than a file).
|
||||
// If it is, we may need to do special processing, such as adding a watch for new
|
||||
// directories if IncludeSubdirectories is enabled. Since we're only watching
|
||||
|
||||
@@ -250,4 +250,22 @@ public class ChangedTests
|
||||
Utility.ExpectNoEvent(are, "symlink'd file change");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void FileSystemWatcher_Changed_RootFolderChangeDoesNotFireEvent()
|
||||
{
|
||||
using (var dir = Utility.CreateTestDirectory())
|
||||
using (var watcher = new FileSystemWatcher())
|
||||
{
|
||||
AutoResetEvent are = Utility.WatchForEvents(watcher, WatcherChangeTypes.Changed);
|
||||
|
||||
// Setup the watcher
|
||||
watcher.Path = Path.GetFullPath(dir.Path);
|
||||
watcher.Filter = "*";
|
||||
watcher.EnableRaisingEvents = true;
|
||||
|
||||
Directory.SetLastWriteTime(dir.Path, DateTime.Now.AddSeconds(10));
|
||||
Utility.ExpectNoEvent(are, "Root Directory Change");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user