Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sources/NextcloudFileProviderKit/Item/Item.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
22 changes: 22 additions & 0 deletions Tests/NextcloudFileProviderKitTests/ItemPropertyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down