Favour straight return in updateItemMetadatas rather than unnecessary completionHandler in NextcloudFilesDatabaseManager

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-03-18 13:23:53 +01:00
parent 0526079504
commit a779fe76cb
No known key found for this signature in database
GPG key ID: C839200C384636B0
2 changed files with 6 additions and 6 deletions

View file

@ -175,7 +175,7 @@ class NextcloudFilesDatabaseManager : NSObject {
return (returningNewMetadatas, returningUpdatedMetadatas, directoriesNeedingRename)
}
func updateItemMetadatas(account: String, serverUrl: String, updatedMetadatas: [NextcloudItemMetadataTable], updateDirectoryEtags: Bool, completionHandler: @escaping(_ newMetadatas: [NextcloudItemMetadataTable]?, _ updatedMetadatas: [NextcloudItemMetadataTable]?, _ deletedMetadatas: [NextcloudItemMetadataTable]?) -> Void) {
func updateItemMetadatas(account: String, serverUrl: String, updatedMetadatas: [NextcloudItemMetadataTable], updateDirectoryEtags: Bool) -> (newMetadatas: [NextcloudItemMetadataTable]?, updatedMetadatas: [NextcloudItemMetadataTable]?, deletedMetadatas: [NextcloudItemMetadataTable]?) {
let database = ncDatabase()
do {
@ -213,10 +213,10 @@ class NextcloudFilesDatabaseManager : NSObject {
}
}
completionHandler(metadatasToCreate, metadatasToUpdate, metadatasToDelete)
return (newMetadatas: metadatasToCreate, updatedMetadatas: metadatasToUpdate, deletedMetadatas: metadatasToDelete)
} catch let error {
Logger.ncFilesDatabase.error("Could not update any item metadatas, received error: \(error.localizedDescription, privacy: .public)")
completionHandler(nil, nil, nil)
return (nil, nil, nil)
}
}

View file

@ -610,9 +610,9 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
// that our local copies are up to date -- instead, leave them as the old.
// They will get updated when they are the subject of a readServerUrl call.
// (See above)
dbManager.updateItemMetadatas(account: ncKitAccount, serverUrl: serverUrl, updatedMetadatas: metadatas, updateDirectoryEtags: false) { newMetadatas, updatedMetadatas, deletedMetadatas in
completionHandler(metadatas, newMetadatas, updatedMetadatas, deletedMetadatas, nil)
}
let changedMetadatas = dbManager.updateItemMetadatas(account: ncKitAccount, serverUrl: serverUrl, updatedMetadatas: metadatas, updateDirectoryEtags: false)
completionHandler(metadatas, changedMetadatas.newMetadatas, changedMetadatas.updatedMetadatas, changedMetadatas.deletedMetadatas, nil)
}
}
}