On OSX 10.8.x, I am using FSEvents to detect changes in a directory.
The problem is that when a file is copied via sftp, the FSEvents callback is not called.
When I am using cp
to copy a file (or touch
to simulate a change), the callback is called.
Am I doing something stupid ? Is sshd using some sort of low level API to create the file ? Should I file a bug to Apple ?
eventQueue = dispatch_queue_create(EVENT_QUEUE_NAME, DISPATCH_QUEUE_SERIAL);
//Watch the data/apns directory (for .json files)
NSString *pathToWatch = ...
NSArray *pathsToWatch = @[pathToWatch];
CFAbsoluteTime latency = 1.0; /* Latency in seconds */
// Create the FileSystem events stream, passing in a callback
streamRef = FSEventStreamCreate(NULL,
&fscallback,
NULL,
(__bridge CFArrayRef)(pathsToWatch),
kFSEventStreamEventIdSinceNow,
latency,
kFSEventStreamCreateFlagIgnoreSelf);
if (streamRef)
{
FSEventStreamSetDispatchQueue(streamRef, eventQueue);
if (NO == FSEventStreamStart(streamRef))
{
DDLogError(@"FSEventStreamStart error");
}
else
{
DDLogError(@"FSEventStreamStart ok");
}
}
else
{
DDLogError(@"FSEventStreamCreate error");
}
I am using internal-sftp in the sshd config:
...
Subsystem sftp internal-sftp
Match Group users
PasswordAuthentication yes
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp
Match User user
ChrootDirectory /vhosts/web/user