From 4d3e63009c5099b1bbee7749e54beabdf92fd3ad Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Mar 2024 18:57:28 +0800 Subject: [PATCH] Add method to ShareTableViewDataSource to fetch the given item's metadata Signed-off-by: Claudio Cambra --- .../ShareTableViewDataSource.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index e5f54996d..7c03ef60f 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -163,6 +163,23 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele } } + private func fetchItemMetadata(itemRelativePath: String) async -> NKFile? { + return await withCheckedContinuation { continuation in + kit?.readFileOrFolder(serverUrlFileName: itemRelativePath, depth: "0") { + account, files, data, error in + guard error == .success else { + let errorString = "Error getting item metadata: \(error.errorDescription)" + Logger.sharesDataSource.error("\(errorString)") + Task { @MainActor in self.uiDelegate?.showError(errorString) } + continuation.resume(returning: nil) + return + } + Logger.sharesDataSource.info("Successfully retrieved item metadata") + continuation.resume(returning: files.first) + } + } + } + // MARK: - NSTableViewDataSource protocol methods @objc func numberOfRows(in tableView: NSTableView) -> Int {