From 64344eeab6e95f88d464433fc5c77d8aa62ddf36 Mon Sep 17 00:00:00 2001 From: Patrick Robertson Date: Mon, 21 Aug 2023 18:47:40 +0800 Subject: [PATCH] Fix bug introduced by 58741f7 - when watching folders, also watch the root (top) folder My previous code changes meant only the sub-folders were watched, and not the main folder. This is now fixed here --- .../QSCorePlugIn/Code/QSFileSystemObjectSource.m | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSFileSystemObjectSource.m b/Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSFileSystemObjectSource.m index 86007ea58..390f47c57 100644 --- a/Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSFileSystemObjectSource.m +++ b/Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSFileSystemObjectSource.m @@ -332,9 +332,9 @@ - (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]; } @@ -342,9 +342,12 @@ - (void)enableWatching { 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]; + } } @@ -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]; + } } @@ -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; }