mirror of
https://github.com/haiwen/seafile.git
synced 2025-01-09 04:17:30 +08:00
[mac] Add kFSEventStreamCreateFlagWatchRoot and handle it
This commit is contained in:
parent
c28f8cfd36
commit
4565b14a75
@ -145,6 +145,12 @@ process_one_event (const char* eventPath,
|
||||
} else if (eventFlags & kFSEventStreamEventFlagItemXattrMod) {
|
||||
seaf_debug ("XattrMod %s.\n", filename);
|
||||
add_event_to_queue (status, WT_EVENT_ATTRIB, filename, NULL);
|
||||
} else if (eventFlags & kFSEventStreamEventFlagRootChanged) {
|
||||
/* An empty path indicates repo-mgr to scan the whole worktree. */
|
||||
seaf_debug ("RootChange event.\n");
|
||||
add_event_to_queue (info->status, WT_EVENT_CREATE_OR_UPDATE, "", NULL);
|
||||
} else {
|
||||
seaf_debug ("Unhandled event with flags %x.\n", eventFlags);
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
@ -185,16 +191,17 @@ static FSEventStreamRef
|
||||
add_watch (SeafWTMonitor *monitor, const char* repo_id, const char* worktree)
|
||||
{
|
||||
SeafWTMonitorPriv *priv = monitor->priv;
|
||||
const char *path = worktree;
|
||||
RepoWatchInfo *info;
|
||||
double latency = 0.25; /* unit: second */
|
||||
|
||||
CFStringRef mypath = CFStringCreateWithCString (kCFAllocatorDefault,
|
||||
path, kCFStringEncodingUTF8);
|
||||
CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)&mypath, 1, NULL);
|
||||
CFStringRef mypaths[1];
|
||||
mypaths[0] = CFStringCreateWithCString (kCFAllocatorDefault,
|
||||
worktree, kCFStringEncodingUTF8);
|
||||
CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)mypaths, 1, NULL);
|
||||
FSEventStreamRef stream;
|
||||
|
||||
/* Create the stream, passing in a callback */
|
||||
seaf_debug("Use kFSEventStreamCreateFlagFileEvents | kFSEventStreamCreateFlagWatchRoot\n");
|
||||
struct FSEventStreamContext ctx = {0, monitor, NULL, NULL, NULL};
|
||||
stream = FSEventStreamCreate(kCFAllocatorDefault,
|
||||
stream_callback,
|
||||
@ -202,10 +209,10 @@ add_watch (SeafWTMonitor *monitor, const char* repo_id, const char* worktree)
|
||||
pathsToWatch,
|
||||
kFSEventStreamEventIdSinceNow,
|
||||
latency,
|
||||
kFSEventStreamCreateFlagFileEvents /* deprecated OSX 10.6 support*/
|
||||
);
|
||||
kFSEventStreamCreateFlagFileEvents | kFSEventStreamCreateFlagWatchRoot
|
||||
);
|
||||
|
||||
CFRelease (mypath);
|
||||
CFRelease (mypaths[0]);
|
||||
CFRelease (pathsToWatch);
|
||||
|
||||
if (!stream) {
|
||||
|
Loading…
Reference in New Issue
Block a user