diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift index ee44645a4..3827e6a47 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift @@ -199,6 +199,13 @@ class NextcloudFilesDatabaseManager : NSObject { let metadatasToAdd = Array(metadatasToUpdate.map { NextcloudItemMetadataTable(value: $0) }) + Array(metadatasToCreate.map { NextcloudItemMetadataTable(value: $0) }) + for metadata in directoriesNeedingRename { + + if let updatedDirectoryChildren = renameDirectoryAndPropagateToChildren(ocId: metadata.ocId, newServerUrl: metadata.serverUrl, newFileName: metadata.fileName) { + metadatasToUpdate += updatedDirectoryChildren + } + } + try database.write { for metadata in metadatasToDelete { // Can't pass copies, we need the originals from the database @@ -211,12 +218,6 @@ class NextcloudFilesDatabaseManager : NSObject { } - for metadata in directoriesNeedingRename { - if let updatedDirectoryChildren = renameDirectoryAndPropagateToChildren(ocId: metadata.ocId, newServerUrl: metadata.serverUrl, newFileName: metadata.fileName) { - metadatasToUpdate += updatedDirectoryChildren - } - } - 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)")