Skip to content

Commit

Permalink
Fix bug introduced by 58741f7 - when watching folders, also watch the…
Browse files Browse the repository at this point in the history
… root (top) folder

My previous code changes meant only the sub-folders were watched, and not the main folder. This is now fixed here
  • Loading branch information
pjrobertson committed Aug 21, 2023
1 parent 9bb9c05 commit 64344ee
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,19 +332,22 @@ - (void)enableWatching {
NSArray *paths = self.fullWatchPaths;
NSNotificationCenter *wsNotif = [[NSWorkspace sharedWorkspace] notificationCenter];
for (NSString *path in paths) {
[[QSVoyeur sharedInstance] addPath:path notifyingAbout:NOTE_DELETE | NOTE_WRITE];
[[QSVoyeur sharedInstance] addPath:path notifyingAbout:NOTE_DELETE | NOTE_WRITE | NOTE_RENAME];
#ifdef DEBUG
if (VERBOSE) NSLog(@"Watching Path %@", path);
NSLog(@"Watching Path %@", path);
#endif
[wsNotif addObserver:self selector:@selector(invalidateIndex:) name:nil object:path];
}
paths = settings[kQSWatchPaths];
for (NSString * p in paths) {
[[QSVoyeur sharedInstance] addPath:p];
#ifdef DEBIG
if (VERBOSE) NSLog(@"Watching Path %@", p);
NSLog(@"Watching Path %@", p);
#endif
[wsNotif addObserver:self selector:@selector(invalidateIndex:) name:VDKQueueWriteNotification object:p];
[wsNotif addObserver:self selector:@selector(invalidateIndex:) name:VDKQueueDeleteNotification object:p];
[wsNotif addObserver:self selector:@selector(invalidateIndex:) name:VDKQueueRenameNotification object:p];

}
}

Expand All @@ -361,6 +364,9 @@ - (void)disableWatching {
for (NSString *p in self.sourceSettings[kQSWatchPaths]) {
[[QSVoyeur sharedInstance] removePath:p];
[wsNotif removeObserver:self name:VDKQueueWriteNotification object:p];
[wsNotif removeObserver:self name:VDKQueueDeleteNotification object:p];
[wsNotif removeObserver:self name:VDKQueueRenameNotification object:p];

}
}

Expand All @@ -383,8 +389,10 @@ - (NSArray *)fullWatchPaths {
if (depth == 1) {
return @[itemPath];
}
NSArray *files = @[itemPath];
QSDirectoryParser *parser = [QSDirectoryParser new];
NSArray *files = [[parser objectsFromPath:itemPath depth:depth types:@[@"public.folder"] excludeTypes:nil descend:NO] arrayByPerformingSelector:@selector(singleFilePath)];
NSArray *descendentFiles = [parser objectsFromPath:itemPath depth:depth types:@[@"public.folder"] excludeTypes:nil descend:NO];
files = [files arrayByAddingObjectsFromArray:[descendentFiles arrayByPerformingSelector:@selector(singleFilePath)]];
return files;
}

Expand Down

0 comments on commit 64344ee

Please sign in to comment.