Add check to detect if we timed out wait for file provider extension service response...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 9 Jul 2024 06:48:47 +0000 (14:48 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 9 Jul 2024 06:48:47 +0000 (14:48 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/macOS/fileproviderxpc_mac.mm

index 5db62867fb139395062398d43fd964e0562b4904..cc0b7b4679230659ba5c02392f3e67b1febb99b2 100644 (file)
@@ -152,13 +152,19 @@ std::optional<std::pair<bool, bool>> FileProviderXPC::fastEnumerationStateForExt
 
     __block BOOL receivedFastEnumerationEnabled; // What is the value of the setting being used by the extension?
     __block BOOL receivedFastEnumerationSet; // Has the setting been set by the user?
+    __block BOOL receivedResponse = NO;
     dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
     [service getFastEnumerationStateWithCompletionHandler:^(BOOL enabled, BOOL set) {
         receivedFastEnumerationEnabled = enabled;
         receivedFastEnumerationSet = set;
+        receivedResponse = YES;
         dispatch_semaphore_signal(semaphore);
     }];
     dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, semaphoreWaitDelta));
+    if (!receivedResponse) {
+        qCWarning(lcFileProviderXPC) << "Did not receive response for fast enumeration state";
+        return std::nullopt;
+    }
     return std::optional<std::pair<bool, bool>>{{receivedFastEnumerationEnabled, receivedFastEnumerationSet}};
 }