From 006eec31b61ffe1640fce8c52a6b2336504c997f Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 14 Apr 2023 00:01:42 +0300 Subject: [PATCH] iOS. + '_query = nil;' --- ios/RNCloudFs.m | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ios/RNCloudFs.m b/ios/RNCloudFs.m index 16febb1..614074d 100644 --- a/ios/RNCloudFs.m +++ b/ios/RNCloudFs.m @@ -226,6 +226,7 @@ - (void)getIcloudDocumentRecurse NSMetadataQuery *query = [notification object]; [query disableUpdates]; [query stopQuery]; + _query = nil; if ([query resultCount] < 1) { return resolver(nil); @@ -291,6 +292,7 @@ - (void)getIcloudDocumentRecurse NSMetadataQuery *query = [notification object]; [query disableUpdates]; [query stopQuery]; + _query = nil; if ([query resultCount] < 1) { return resolver(nil); @@ -541,16 +543,6 @@ - (BOOL)startFileDownloadIfNotAvailable:(NSMetadataItem*)item { [_query setSearchScopes:@[NSMetadataQueryUbiquitousDocumentsScope, NSMetadataQueryUbiquitousDataScope]]; [_query setPredicate:[NSPredicate predicateWithFormat: @"%K LIKE '*'", NSMetadataItemFSNameKey]]; - - dispatch_async(dispatch_get_main_queue(), ^{ - - BOOL startedQuery = [self->_query startQuery]; - if (!startedQuery) - { - reject(@"error", @"Failed to start query.\n", nil); - } - }); - [[NSNotificationCenter defaultCenter] addObserverForName: NSMetadataQueryDidFinishGatheringNotification object:_query @@ -560,12 +552,22 @@ - (BOOL)startFileDownloadIfNotAvailable:(NSMetadataItem*)item { NSMetadataQuery *query = [notification object]; [query disableUpdates]; [query stopQuery]; + _query = nil; + for (NSMetadataItem *item in query.results) { [self startFileDownloadIfNotAvailable: item]; } + return resolve(@YES); }]; + dispatch_async(dispatch_get_main_queue(), ^{ + BOOL startedQuery = [self->_query startQuery]; + if (!startedQuery) + { + reject(@"error", @"Failed to start query.\n", nil); + } + }); } @end