From 72d1fb219ff3bbad4adedddb9671cf97f3cd4afe Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 30 May 2025 13:00:23 +0800 Subject: [PATCH 1/2] Add userInfo entry for items if they are shareable Signed-off-by: Claudio Cambra --- Sources/NextcloudFileProviderKit/Item/Item.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/NextcloudFileProviderKit/Item/Item.swift b/Sources/NextcloudFileProviderKit/Item/Item.swift index b775f43d..cdae8169 100644 --- a/Sources/NextcloudFileProviderKit/Item/Item.swift +++ b/Sources/NextcloudFileProviderKit/Item/Item.swift @@ -204,6 +204,12 @@ public class Item: NSObject, NSFileProviderItem { } else { userInfoDict["displayEvict"] = metadata.downloaded } + // https://docs.nextcloud.com/server/latest/developer_manual/client_apis/WebDAV/basic.html + if metadata.permissions.uppercased().contains("R"), // Shareable + ![.rootContainer, .trashContainer].contains(itemIdentifier) + { + userInfoDict["displayShare"] = true + } return userInfoDict } From 8cd22c111f294c874024cb75d798475774fedcda Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 30 May 2025 13:06:30 +0800 Subject: [PATCH 2/2] Add test for displayShare in userInfo of Item Signed-off-by: Claudio Cambra --- .../ItemPropertyTests.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Tests/NextcloudFileProviderKitTests/ItemPropertyTests.swift b/Tests/NextcloudFileProviderKitTests/ItemPropertyTests.swift index 4a754349..50081e93 100644 --- a/Tests/NextcloudFileProviderKitTests/ItemPropertyTests.swift +++ b/Tests/NextcloudFileProviderKitTests/ItemPropertyTests.swift @@ -322,6 +322,28 @@ final class ItemPropertyTests: XCTestCase { XCTAssertEqual(itemD.userInfo?["displayEvict"] as? Bool, true) } + func testItemUserInfoDisplayShare() { + var metadata = + SendableItemMetadata(ocId: "test-id", fileName: "test.txt", account: Self.account) + metadata.permissions = "GDNVW" // No "R" for shareable + + let item = Item( + metadata: metadata, + parentItemIdentifier: .rootContainer, + account: Self.account, + remoteInterface: MockRemoteInterface(), + dbManager: Self.dbManager + ) + + XCTAssertNil(item.userInfo?["displayShare"]) + + let fileproviderItems = ["fileproviderItems": [item]] + let lockPredicate = NSPredicate( + format: "SUBQUERY ( fileproviderItems, $fileproviderItem, $fileproviderItem.userInfo.displayShare == nil ).@count > 0" + ) + XCTAssertTrue(lockPredicate.evaluate(with: fileproviderItems)) + } + func testItemLockFileUntrashable() { let metadata = SendableItemMetadata( ocId: "test-id", fileName: ".~lock.test.doc#", account: Self.account