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;