Created attachment 4847 [details]
From case #45521
Using the example provided, the FileSystemWatcher events aren't being handled properly. Only the Changed event is firing, and the ChangeType is always Changed.
Here is my initial request:
I use Mono on Mac OS X and it seems neither KeventWatcher nor DefaultWatcher implementation of IFileWatcher interface doesn't send Renamed event and thus it is impossible to catch this event when the user renames file or folder. I always get Deleted and Created events successively.
Use MonoMac.CoreServices.FSEvents for now. Here's a sample: https://github.com/xamarin/mac-samples/tree/master/FSEvents
Mono at some point in the future should probably use FSEvents internally for FileSystemWatcher, but it does not. The behavior you are looking for is however available in Xamarin.Mac.
Moving this to Mono itself since this is not a bug in Xamarin.Mac.
Yes, it is what I finally used.
Hi, i would like to fix this. Is anyone
Sorry for my last comment, i would like to fix, i have seen in code that all events are considerated. is this still a problem?
Bug confirmed with Mono 3.10.0 on OS X 10.9.5.
I have created this watcher which inherits from FileSystemWatcher:
Path = System.IO.Path.GetFullPath(folder);
IncludeSubdirectories = true;
Filter = "*";
InternalBufferSize = 4 * 1024 * 16;
NotifyFilter = NotifyFilters.Size |
NotifyFilters.FileName | NotifyFilters.DirectoryName;
Error += new ErrorEventHandler(OnError);
Created += new FileSystemEventHandler(OnCreated);
Deleted += new FileSystemEventHandler(OnDeleted);
Changed += new FileSystemEventHandler(OnChanged);
Renamed += new RenamedEventHandler(OnRenamed);
On both Windows and Mono/OS X, I tried renaming `file.txt` to `file2.txt` at the root of the watched folder.
Works great: I receive one Renamed (name=file2.txt oldName=file.txt).
Unfortunately I receive 3 events:
1. Changed: file.txt
2. Created: file2.txt
3. Deleted: file.txt
Same result with Environment.SetEnvironmentVariable("MONO_MANAGED_WATCHER", "enabled");
This is problematic for my sync software: syncing deletion/creation to remote is inefficient and looses precious file metadata.