Fix recursive directory metadata renaming order

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-03-18 20:01:29 +01:00
parent 9cc05457c0
commit 02e1d6a47f
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -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)")