From a779fe76cbb47b832633d1fdd2d576710ec34806 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sat, 18 Mar 2023 13:23:53 +0100 Subject: [PATCH] Favour straight return in updateItemMetadatas rather than unnecessary completionHandler in NextcloudFilesDatabaseManager Signed-off-by: Claudio Cambra --- .../Database/NextcloudFilesDatabaseManager.swift | 6 +++--- .../FileProviderExt/FileProviderEnumerator.swift | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift index edf402dd2..bdd0a6b73 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift @@ -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) } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift index 711255dcb..ec28fb0e8 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift @@ -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) } } }