Skip to content

Commit

Permalink
Fix handling of root container metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed May 15, 2024
1 parent ce9083c commit 5e5b575
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* for more details.
*/

import FileProvider
import Foundation
import OSLog

Expand Down Expand Up @@ -40,9 +41,15 @@ extension FilesDatabaseManager {
}

public func childItemsForDirectory(_ directoryMetadata: ItemMetadata) -> [ItemMetadata] {
let directoryServerUrl = directoryMetadata.serverUrl + "/" + directoryMetadata.fileName
var directoryServerUrl: String
if directoryMetadata.ocId == NSFileProviderItemIdentifier.rootContainer.rawValue {
directoryServerUrl = directoryMetadata.serverUrl
} else {
directoryServerUrl = directoryMetadata.serverUrl + "/" + directoryMetadata.fileName
}
let metadatas = ncDatabase().objects(ItemMetadata.self).filter(
"serverUrl BEGINSWITH %@", directoryServerUrl)
"serverUrl BEGINSWITH %@", directoryServerUrl
)
return sortedItemMetadatas(metadatas)
}

Expand Down
2 changes: 0 additions & 2 deletions Sources/NextcloudFileProviderKit/Item/Item.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ public class Item: NSObject, NSFileProviderItem {
metadata.account = ncKit.nkCommonInstance.account
metadata.directory = true
metadata.ocId = NSFileProviderItemIdentifier.rootContainer.rawValue
metadata.fileName = "root"
metadata.fileNameView = "root"
metadata.serverUrl = ncKit.nkCommonInstance.urlBase
metadata.classFile = NKCommon.TypeClassFile.directory.rawValue
return Item(metadata: metadata, parentItemIdentifier: .rootContainer, ncKit: ncKit)
Expand Down

0 comments on commit 5e5b575

Please sign in to comment.