mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-24 05:55:59 +03:00
Fix scan path to retrieve item metadata in share table view data source
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
9621dede1f
commit
807371e1b7
1 changed files with 26 additions and 1 deletions
|
@ -173,8 +173,33 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele
|
|||
}
|
||||
|
||||
private func fetchItemMetadata(itemRelativePath: String) async -> NKFile? {
|
||||
guard let kit = kit else {
|
||||
let errorString = "Could not fetch item metadata as nckit unavailable"
|
||||
Logger.sharesDataSource.error("\(errorString, privacy: .public)")
|
||||
Task { @MainActor in self.uiDelegate?.showError(errorString) }
|
||||
return nil
|
||||
}
|
||||
|
||||
func slashlessPath(_ string: String) -> String {
|
||||
var strCopy = string
|
||||
if strCopy.hasPrefix("/") {
|
||||
strCopy.removeFirst()
|
||||
}
|
||||
if strCopy.hasSuffix("/") {
|
||||
strCopy.removeLast()
|
||||
}
|
||||
return strCopy
|
||||
}
|
||||
|
||||
let nkCommon = kit.nkCommonInstance
|
||||
let urlBase = slashlessPath(nkCommon.urlBase)
|
||||
let davSuffix = slashlessPath(nkCommon.dav)
|
||||
let userId = nkCommon.userId
|
||||
let itemRelPath = slashlessPath(itemRelativePath)
|
||||
|
||||
let itemFullServerPath = "\(urlBase)/\(davSuffix)/files/\(userId)/\(itemRelPath)"
|
||||
return await withCheckedContinuation { continuation in
|
||||
kit?.readFileOrFolder(serverUrlFileName: itemRelativePath, depth: "0") {
|
||||
kit.readFileOrFolder(serverUrlFileName: itemFullServerPath, depth: "0") {
|
||||
account, files, data, error in
|
||||
guard error == .success else {
|
||||
let errorString = "Error getting item metadata: \(error.errorDescription)"
|
||||
|
|
Loading…
Reference in a new issue