Merge pull request #615 from ajdavis/catalina-inotify-fix

Remove /System/Volumes/Data from fsevent paths on macOS
This commit is contained in:
Daniel Poelzleithner 2021-12-09 15:43:27 +01:00 committed by GitHub
commit dcebacb554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -34,6 +34,9 @@ if( WITH_FSEVENTS )
include_directories( ${XNU_DIR} ) include_directories( ${XNU_DIR} )
endif( WITH_FSEVENTS ) endif( WITH_FSEVENTS )
if ( APPLE )
set( LSYNCD_TARGET_APPLE 1 )
endif ( APPLE )
# generating the config.h file # generating the config.h file
configure_file ( configure_file (

View File

@ -4,3 +4,6 @@
/* File event notification mechanims available */ /* File event notification mechanims available */
#cmakedefine WITH_INOTIFY 1 #cmakedefine WITH_INOTIFY 1
#cmakedefine WITH_FSEVENTS 1 #cmakedefine WITH_FSEVENTS 1
/* OS */
#cmakedefine LSYNCD_TARGET_APPLE 1

View File

@ -153,6 +153,10 @@ handle_event(lua_State *L, struct kfs_event *event, ssize_t mlen)
const char *trg = NULL; const char *trg = NULL;
const char *etype = NULL; const char *etype = NULL;
int isdir = -1; int isdir = -1;
#ifdef LSYNCD_TARGET_APPLE \
// Since macOS 10.15, fsevent paths are prefixed with this string.
const char *const INOTIFY_PREFIX = "/System/Volumes/Data";
#endif
if (event->type == FSE_EVENTS_DROPPED) { if (event->type == FSE_EVENTS_DROPPED) {
logstring("Fsevents", "Events dropped!"); logstring("Fsevents", "Events dropped!");
@ -265,6 +269,11 @@ handle_event(lua_State *L, struct kfs_event *event, ssize_t mlen)
lua_pushstring(L, etype); lua_pushstring(L, etype);
lua_pushboolean(L, isdir); lua_pushboolean(L, isdir);
l_now(L); l_now(L);
#ifdef LSYNCD_TARGET_APPLE
if (!strncmp(path, INOTIFY_PREFIX, strlen(INOTIFY_PREFIX ))) {
path += strlen(INOTIFY_PREFIX);
}
#endif
lua_pushstring(L, path); lua_pushstring(L, path);
if (trg) { if (trg) {
lua_pushstring(L, trg); lua_pushstring(L, trg);