Handle version item requests in fetchContents of FileProviderExtension per the docume...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 7 Mar 2023 12:47:01 +0000 (13:47 +0100)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 12 May 2023 05:21:20 +0000 (13:21 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension.swift

index 2a5dbd87ef075f5f3150eb45aff5b4cd17749eec..5653e5e6dd709615dc7c7bc88c633f711d671150 100644 (file)
@@ -112,6 +112,19 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
 
         NSLog("Received request to fetch contents of item with identifier: %@", itemIdentifier.rawValue)
 
+        guard requestedVersion == nil else {
+            // TODO: Add proper support for file versioning
+            NSLog("Can't return contents for specific version as this is not supported.")
+            completionHandler(nil, nil, NSError(domain: NSCocoaErrorDomain, code: NSFeatureUnsupportedError, userInfo:[:]))
+            return Progress()
+        }
+
+        guard ncAccount != nil else {
+            NSLog("Not fetching contents item: %@ as account not set up yet", itemIdentifier.rawValue)
+            completionHandler(nil, nil, NSFileProviderError(.notAuthenticated))
+            return Progress()
+        }
+
         let dbManager = NextcloudFilesDatabaseManager.shared
         let ocId = itemIdentifier.rawValue
         guard let metadata = dbManager.itemMetadataFromOcId(ocId) else {