]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Greatly simplify item method of FIleProviderExtension by using item storedItem method
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 15 Apr 2024 14:41:22 +0000 (22:41 +0800)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Wed, 17 Apr 2024 08:44:12 +0000 (08:44 +0000)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension.swift

index 881894cb966651264350405d5187bee560d374e1..cddbdf8a0c90a710259f08b20491e789d9b5270d 100644 (file)
@@ -92,37 +92,11 @@ import OSLog
         request _: NSFileProviderRequest,
         completionHandler: @escaping (NSFileProviderItem?, Error?) -> Void
     ) -> Progress {
-        // resolve the given identifier to a record in the model
-
-        Logger.fileProviderExtension.debug(
-            "Received item request for item with identifier: \(identifier.rawValue, privacy: .public)"
-        )
-
-        if identifier == .rootContainer {
-            guard ncAccount != nil else {
-                Logger.fileProviderExtension.error(
-                    "Not providing item: \(identifier.rawValue, privacy: .public) as account not set up yet"
-                )
-                completionHandler(nil, NSFileProviderError(.notAuthenticated))
-                return Progress()
-            }
-
-            completionHandler(Item.rootContainer(ncKit: ncKit), nil)
-            return Progress()
-        }
-
-        let dbManager = FilesDatabaseManager.shared
-
-        guard let metadata = dbManager.itemMetadataFromFileProviderItemIdentifier(identifier),
-              let parentItemIdentifier = dbManager.parentItemIdentifierFromMetadata(metadata)
-        else {
+        if let item = Item.storedItem(identifier: identifier, usingKit: ncKit) {
+            completionHandler(item, nil)
+        } else {
             completionHandler(nil, NSFileProviderError(.noSuchItem))
-            return Progress()
         }
-
-        completionHandler(
-            Item(metadata: metadata, parentItemIdentifier: parentItemIdentifier, ncKit: ncKit), nil
-        )
         return Progress()
     }