Module notify::op [−][src]
Contains the Op
type which describes the actions for an event.
notify
aims to provide unified behavior across platforms. This however is not always possible
due to the underlying technology of the various operating systems. So there are some issues
notify
-API users will have to take care of themselves, depending on their needs.
Chmod
Linux, macOS
On Linux and macOS the CHMOD
event is emitted whenever attributes or extended attributes
change.
Windows
On Windows a WRITE
event is emitted when attributes change. This makes it impossible to
distinguish between writes to a file or its meta data.
Close-Write
A CLOSE_WRITE
event is emitted whenever a file that was opened for writing has been closed.
This event is only available on Linux.
Create
A CREATE
event is emitted whenever a new file or directory is created.
Upon receiving a Create
event for a directory, it is necessary to scan the newly created
directory for contents. The directory can contain files or directories if those contents were
created before the directory could be watched, or if the directory was moved into the watched
directory.
Remove
Remove file or directory within a watched directory
A REMOVE
event is emitted whenever a file or directory is removed.
Remove watched file or directory itself
With the exception of Windows a REMOVE
event is emitted whenever the watched file or
directory itself is removed. The behavior after the remove differs between platforms though.
Linux
When a watched file or directory is removed, its watch gets destroyed and no new events will be sent.
Windows
If a watched directory is removed, an empty event is emitted.
When watching a single file on Windows, the file path will continue to be watched until either the watch is removed by the API user or the parent directory gets removed.
When watching a directory on Windows, the watch will get destroyed and no new events will be sent.
macOS
While Linux and Windows monitor “inodes”, macOS monitors “paths”. So a watch stays active even after the watched file or directory has been removed and it will emit events in case a new file or directory is created in its place.
Rename
A RENAME
event is emitted whenever a file or directory has been renamed or moved to a
different directory.
Rename file or directory within a watched directory
Linux, Windows
A rename with both the source and the destination path inside a watched directory produces two
RENAME
events. The first event contains the source path, the second contains the destination
path. Both events share the same cookie.
A rename that originates inside of a watched directory but ends outside of a watched directory
produces a DELETE
event.
A rename that originates outside of a watched directory and ends inside of a watched directory
produces a CREATE
event.
macOS
A RENAME
event is produced whenever a file or directory is moved. This includes moves within
the watched directory as well as moves into or out of the watched directory. It is up to the
API user to determine what exactly happened. Usually when a move within a watched directory
occurs, the cookie is set for both connected events. This can however fail eg. if a file gets
renamed multiple times without a delay (test fsevents_rename_rename_file_0
). So in some cases
rename cannot be caught properly but would be interpreted as a sequence of events where a file
or directory is moved out of the watched directory and a different file or directory is moved
in.
Rename watched file or directory itself
With the exception of Windows a RENAME
event is emitted whenever the watched file or
directory itself is renamed. The behavior after the rename differs between platforms though.
Depending on the platform either the moved file or directory will continue to be watched or the
old path. If the moved file or directory will continue to be watched, the paths of emitted
events will still be prefixed with the old path though.
Linux
Linux will continue to watch the moved file or directory. Events will contain paths prefixed with the old path.
Windows
Currently there is no event emitted when a watched directory is renamed. But the directory will continue to be watched and events will contain paths prefixed with the old path.
When renaming a watched file, a RENAME
event is emitted but the old path will continue to be
watched.
macOS
macOS will continue to watch the (now non-existing) path.
Rename parent directory of watched file or directory
Currently no event will be emitted when any parent directory of the watched file or directory is renamed. Depending on the platform either the moved file or directory will continue to be watched or the old path. If the moved file or directory will continue to be watched, the paths of emitted events will still be prefixed with the old path though.
Linux, Windows
Linux and Windows will continue to watch the moved file or directory. Events will contain paths prefixed with the old path.
macOS
macOS will continue to watch the (now non-existing) path.
Rescan
A RESCAN
event indicates that an error occurred and the watched directories need to be
rescanned. This can happen if the internal event queue has overflown and some events were
dropped. Or with FSEvents if events were coalesced hierarchically.
Windows
At the moment RESCAN
events aren’t emitted on Windows.
Queue size
Linux: /proc/sys/fs/inotify/max_queued_events
Windows: 16384 Bytes. The actual amount of events that fit into the queue depends on the length of the paths.
Write
A WRITE
event is emitted whenever a file has been written to.
Windows
On Windows a WRITE
event is emitted when attributes change.
Structs
Op | Holds a set of bit flags representing the actions for the event. |
Constants
CHMOD | |
CLOSE_WRITE | |
CREATE | |
REMOVE | |
RENAME | |
RESCAN | |
WRITE |