Minimise memory usage in Mac app directory watcher
This commit is contained in:
		@@ -55,14 +55,16 @@ void callback(ConstFSEventStreamRef streamRef, void * info, size_t numEvents, vo
 | 
			
		||||
 | 
			
		||||
- (void)rescanPathWithEvents:(BOOL)sendEvents {
 | 
			
		||||
    NSArray<NSString*>* downloadFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:self.path error:nil];
 | 
			
		||||
    NSMutableSet<NSString*>* fullSet = [NSMutableSet new];
 | 
			
		||||
    for (NSString * file in downloadFiles) {
 | 
			
		||||
        [fullSet addObject:file];
 | 
			
		||||
        if (![self.knownFiles containsObject:file]) {
 | 
			
		||||
            if (sendEvents) {
 | 
			
		||||
                [self.delegate watcher:self observedNewFileAtPath:file];
 | 
			
		||||
            }
 | 
			
		||||
            [self.knownFiles addObject:file];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    self.knownFiles = fullSet;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user