From b01de763dafde3d8b7f083b53814ba9a074b4541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20J=2E=20Hern=C3=A1ndez=20Blasco?= Date: Tue, 27 Jan 2015 18:27:11 +0100 Subject: [PATCH] oc: Move back and forth folders now are in sync Two different indexing entries were created on move operation making impossible to restore old folder position in the original parent folder. This was due to cleanupCaches message calls to objectId which requires to have the indexing entry available. Use case: * Restore a folder from "Deleted items" folders --- OpenChange/MAPIStoreFolder.m | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/OpenChange/MAPIStoreFolder.m b/OpenChange/MAPIStoreFolder.m index 5aa59f8c4..19c826d7f 100644 --- a/OpenChange/MAPIStoreFolder.m +++ b/OpenChange/MAPIStoreFolder.m @@ -916,16 +916,23 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe } if (isMove) - { - fmid = [mapping idFromURL: [self url]]; - [mapping unregisterURLWithID: fmid]; [self deleteFolder]; - [mapping registerURL: [newFolder url] - withID: fmid]; - } + [targetFolder cleanupCaches]; } [self cleanupCaches]; + + /* We perform the mapping operations at the + end as objectId is required to be available + until the caches are cleaned up */ + if (isMove && rc == MAPISTORE_SUCCESS) + { + fmid = [mapping idFromURL: [self url]]; + [mapping unregisterURLWithID: fmid]; + [mapping registerURL: [newFolder url] + withID: fmid]; + } + } else rc = MAPISTORE_ERR_DENIED;