fsevents: fix subfolder check
First of all, a bit of explanation of what happens there:
1. FSEvents emits absolute paths to changed files or directories
2. We cut off the first part of such paths, which is equal to handle's
real path ('/dir/subdir/subsubdir`, without trailing slash)
3. Then, if we are running in non-recursive mode, we discard paths that
have slashes ('/') as a non-first character in them
This commit is contained in:
parent
93cc7e5ce1
commit
bf5038df40
@ -251,13 +251,15 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
|
||||
if (strncmp(path, handle->realpath, handle->realpath_len) != 0)
|
||||
continue;
|
||||
|
||||
path += handle->realpath_len;
|
||||
len -= handle->realpath_len;
|
||||
if (handle->realpath_len > 1 || *handle->realpath != '/') {
|
||||
path += handle->realpath_len;
|
||||
len -= handle->realpath_len;
|
||||
|
||||
/* Skip back slash */
|
||||
if (*path != 0) {
|
||||
path++;
|
||||
len--;
|
||||
/* Skip forward slash */
|
||||
if (*path != '\0') {
|
||||
path++;
|
||||
len--;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAC_OS_X_VERSION_10_7
|
||||
@ -267,9 +269,9 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
|
||||
#endif /* MAC_OS_X_VERSION_10_7 */
|
||||
|
||||
/* Do not emit events from subdirectories (without option set) */
|
||||
if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0) {
|
||||
pos = strchr(path, '/');
|
||||
if (pos != NULL && pos != path + 1)
|
||||
if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != 0) {
|
||||
pos = strchr(path + 1, '/');
|
||||
if (pos != NULL)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user