From 1336a1d5a8c2751d88ba9fad17e2652494daa810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Fri, 17 Apr 2015 13:55:39 +0200 Subject: [PATCH 1/2] oc: remove useless mapistore_indexing call [mapping registerURL ...] will insert the mappingId in indexing database there is no need to call, again, mapistore_indexing_record_add_mid --- OpenChange/MAPIStoreContext.m | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index 2a0e1c58e..6a9c43da3 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -480,11 +480,9 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri) - (uint64_t) idForObjectWithKey: (NSString *) key inFolderURL: (NSString *) folderURL { - NSString *childURL, *owner; + NSString *childURL; MAPIStoreMapping *mapping; uint64_t mappingId; - uint32_t contextId; - void *rootObject; if (key) childURL = [NSString stringWithFormat: @"%@%@", folderURL, @@ -495,15 +493,9 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri) mappingId = [mapping idFromURL: childURL]; if (mappingId == NSNotFound) { + [self logWithFormat: @"No id exist yet for '%@', requesting one", childURL]; mapistore_indexing_get_new_folderID (connInfo->mstore_ctx, &mappingId); [mapping registerURL: childURL withID: mappingId]; - contextId = 0; - - mapistore_search_context_by_uri (connInfo->mstore_ctx, [folderURL UTF8String], - &contextId, &rootObject); - owner = [userContext username]; - mapistore_indexing_record_add_mid (connInfo->mstore_ctx, contextId, - [owner UTF8String], mappingId); } return mappingId; From 7bde181d3f7d83895fbb727632fa8300300e5c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Tue, 21 Jul 2015 19:45:03 +0200 Subject: [PATCH 2/2] oc: check ret value get_new_folderID On [MAPIStoreContext idForObjectWithKey: key inFolderUrl: url] check the ret value of mapistore_indexing_get_new_folderID. This should never happen (oh my...) but if this happens it will be reported --- OpenChange/MAPIStoreContext.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index 6a9c43da3..e16b23d9b 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -483,6 +483,7 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri) NSString *childURL; MAPIStoreMapping *mapping; uint64_t mappingId; + enum mapistore_error ret; if (key) childURL = [NSString stringWithFormat: @"%@%@", folderURL, @@ -494,8 +495,12 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri) if (mappingId == NSNotFound) { [self logWithFormat: @"No id exist yet for '%@', requesting one", childURL]; - mapistore_indexing_get_new_folderID (connInfo->mstore_ctx, &mappingId); - [mapping registerURL: childURL withID: mappingId]; + ret = mapistore_indexing_get_new_folderID (connInfo->mstore_ctx, &mappingId); + if (ret == MAPI_E_SUCCESS) + [mapping registerURL: childURL withID: mappingId]; + else + [self errorWithFormat: @"Error trying to get new folder id (%d): %s", + ret, mapistore_errstr (ret)]; } return mappingId;