Make paths absolute before calling $native.watchPath

Also return a subscription that can be unwatched instead
of returning an id that is later passed to $native.unwatchPath
along with the watched path.

This allows specs to pass when run from a symlink'ed folder.
This commit is contained in:
Corey Johnson & Kevin Sawicki
2013-03-20 13:27:49 -07:00
parent ae96a48572
commit 6c357aaca7
5 changed files with 17 additions and 18 deletions

View File

@@ -99,7 +99,6 @@ static NSMutableArray *gPathWatchers;
}
- (NSString *)watchPath:(NSString *)path callback:(WatchCallback)callback callbackId:(NSString *)callbackId {
path = [path stringByStandardizingPath];
@synchronized(self) {
if (![self createKeventForPath:path]) {
NSLog(@"WARNING: Failed to create kevent for path '%@'", path);
@@ -119,8 +118,6 @@ static NSMutableArray *gPathWatchers;
}
- (void)unwatchPath:(NSString *)path callbackId:(NSString *)callbackId error:(NSError **)error {
path = [path stringByStandardizingPath];
@synchronized(self) {
NSMutableDictionary *callbacks = [_callbacksByPath objectForKey:path];
@@ -154,8 +151,6 @@ static NSMutableArray *gPathWatchers;
}
- (bool)createKeventForPath:(NSString *)path {
path = [path stringByStandardizingPath];
@synchronized(self) {
if ([_fileDescriptorsByPath objectForKey:path]) {
NSLog(@"we already have a kevent");
@@ -182,8 +177,6 @@ static NSMutableArray *gPathWatchers;
}
- (void)removeKeventForPath:(NSString *)path {
path = [path stringByStandardizingPath];
@synchronized(self) {
NSNumber *fdNumber = [_fileDescriptorsByPath objectForKey:path];
if (!fdNumber) {
@@ -245,7 +238,7 @@ static NSMutableArray *gPathWatchers;
char pathBuffer[MAXPATHLEN];
fcntl((int)event.ident, F_GETPATH, &pathBuffer);
close(event.ident);
newPath = [[NSString stringWithUTF8String:pathBuffer] stringByStandardizingPath];
newPath = [NSString stringWithUTF8String:pathBuffer];
if (!newPath) {
NSLog(@"WARNING: Ignoring rename event for deleted file '%@'", path);
continue;