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
Родитель 9cc05457c0
Коммит 02e1d6a47f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: C839200C384636B0
1 изменённых файлов: 7 добавлений и 6 удалений

Просмотреть файл

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