Add method to get directory tables from database in manager

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-01-26 18:54:52 +01:00
parent 7ff2379e3d
commit 57d585201e
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -198,6 +198,12 @@ class NextcloudFilesDatabaseManager : NSObject {
return directoryMetadata(account: itemMetadata.account, serverUrl: itemMetadata.serverUrl) return directoryMetadata(account: itemMetadata.account, serverUrl: itemMetadata.serverUrl)
} }
func directoryMetadatas(account: String, parentDirectoryServerUrl: String) -> [NextcloudDirectoryMetadataTable] {
let metadatas = ncDatabase().objects(NextcloudDirectoryMetadataTable.self).filter("account == %@ AND parentDirectoryServerUrl == %@", account, parentDirectoryServerUrl)
let sortedMetadatas = metadatas.sorted(byKeyPath: "serverUrl", ascending: true)
return Array(sortedMetadatas.map { NextcloudDirectoryMetadataTable(value: $0) })
}
private func processDirectoryMetadatasToDelete(databaseToWriteTo: Realm, private func processDirectoryMetadatasToDelete(databaseToWriteTo: Realm,
existingDirectoryMetadatas: [NextcloudDirectoryMetadataTable], existingDirectoryMetadatas: [NextcloudDirectoryMetadataTable],
updatedDirectoryMetadatas: [NextcloudDirectoryMetadataTable]) { updatedDirectoryMetadatas: [NextcloudDirectoryMetadataTable]) {