diff --git a/clients/macuploader/Microbit Uploader/DirectoryWatcher.m b/clients/macuploader/Microbit Uploader/DirectoryWatcher.m index 66290d67..e33fff81 100644 --- a/clients/macuploader/Microbit Uploader/DirectoryWatcher.m +++ b/clients/macuploader/Microbit Uploader/DirectoryWatcher.m @@ -55,14 +55,16 @@ void callback(ConstFSEventStreamRef streamRef, void * info, size_t numEvents, vo - (void)rescanPathWithEvents:(BOOL)sendEvents { NSArray* downloadFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:self.path error:nil]; + NSMutableSet* 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