mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 06:25:56 +03:00
Create sortedDirectoryMetadatas convenience method in database manager
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
64e32b48eb
commit
24d6c5071c
1 changed files with 8 additions and 7 deletions
|
@ -312,27 +312,28 @@ class NextcloudFilesDatabaseManager : NSObject {
|
|||
return nil
|
||||
}
|
||||
|
||||
func childDirectoriesForDirectory(_ directoryMetadata: NextcloudDirectoryMetadataTable) -> [NextcloudDirectoryMetadataTable] {
|
||||
let database = ncDatabase()
|
||||
let metadatas = database.objects(NextcloudDirectoryMetadataTable.self).filter("serverUrl BEGINSWITH %@ AND ocId != %@", directoryMetadata.serverUrl, directoryMetadata.account)
|
||||
private func sortedDirectoryMetadatas(_ metadatas: Results<NextcloudDirectoryMetadataTable>) -> [NextcloudDirectoryMetadataTable] {
|
||||
let sortedMetadatas = metadatas.sorted(byKeyPath: "serverUrl", ascending: true)
|
||||
return Array(sortedMetadatas.map { NextcloudDirectoryMetadataTable(value: $0) })
|
||||
}
|
||||
|
||||
func childDirectoriesForDirectory(_ directoryMetadata: NextcloudDirectoryMetadataTable) -> [NextcloudDirectoryMetadataTable] {
|
||||
let metadatas = ncDatabase().objects(NextcloudDirectoryMetadataTable.self).filter("serverUrl BEGINSWITH %@ AND ocId != %@", directoryMetadata.serverUrl, directoryMetadata.account)
|
||||
return sortedDirectoryMetadatas(metadatas)
|
||||
}
|
||||
|
||||
func parentDirectoryMetadataForItem(_ itemMetadata: NextcloudItemMetadataTable) -> NextcloudDirectoryMetadataTable? {
|
||||
return directoryMetadata(account: itemMetadata.account, serverUrl: itemMetadata.serverUrl)
|
||||
}
|
||||
|
||||
func directoryMetadatas(account: String) -> [NextcloudDirectoryMetadataTable] {
|
||||
let metadatas = ncDatabase().objects(NextcloudDirectoryMetadataTable.self).filter("account == %@", account)
|
||||
let sortedMetadatas = metadatas.sorted(byKeyPath: "serverUrl", ascending: true)
|
||||
return Array(sortedMetadatas.map { NextcloudDirectoryMetadataTable(value: $0) })
|
||||
return sortedDirectoryMetadatas(metadatas)
|
||||
}
|
||||
|
||||
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) })
|
||||
return sortedDirectoryMetadatas(metadatas)
|
||||
}
|
||||
|
||||
private func processDirectoryMetadatasToDelete(databaseToWriteTo: Realm,
|
||||
|
|
Loading…
Reference in a new issue