Merge pull request #122 from Zentyal/ejhernandez/enforce-mapping-subfolder

oc: Enforce the folder creation mapping when the FID exists
pull/79/head^2
Jesús García Sáez 2015-04-16 18:05:29 +02:00
commit d3bf3dcd8f
3 changed files with 32 additions and 5 deletions

View File

@ -402,7 +402,8 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
withRow: (struct SRow *) aRow withRow: (struct SRow *) aRow
andFID: (uint64_t) fid andFID: (uint64_t) fid
{ {
int rc = MAPISTORE_SUCCESS; BOOL mapped;
enum mapistore_error rc = MAPISTORE_SUCCESS;
MAPIStoreMapping *mapping; MAPIStoreMapping *mapping;
NSString *baseURL, *childURL, *folderKey; NSString *baseURL, *childURL, *folderKey;
MAPIStoreFolder *childFolder; MAPIStoreFolder *childFolder;
@ -430,7 +431,12 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
childURL = [NSString stringWithFormat: @"%@%@/", childURL = [NSString stringWithFormat: @"%@%@/",
baseURL, baseURL,
[folderKey stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]; [folderKey stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
[mapping registerURL: childURL withID: fid];
mapped = [mapping registerURL: childURL withID: fid];
if (!mapped)
/* Enforce the creation if the backend does know the fid */
[mapping updateURL: childURL withID: fid];
childFolder = [self lookupFolder: folderKey]; childFolder = [self lookupFolder: folderKey];
if (childFolder) if (childFolder)
{ {

View File

@ -60,6 +60,8 @@
andFlags: (uint8_t) flags; andFlags: (uint8_t) flags;
- (void) updateID: (uint64_t) idNbr - (void) updateID: (uint64_t) idNbr
withURL: (NSString *) urlString; withURL: (NSString *) urlString;
- (BOOL) updateURL: (NSString *) urlString
withID: (uint64_t) idNbr;
@end @end

View File

@ -227,12 +227,32 @@ MAPIStoreMappingKeyFromId (uint64_t idNbr)
} }
} }
- (BOOL) updateURL: (NSString *) urlString
withID: (uint64_t) idNbr
{
BOOL rc = NO;
uint64_t oldIDNbr;
oldIDNbr = [self idFromURL: urlString];
if (oldIDNbr)
{
[self logWithFormat: @"Updating URL: %@ with id %.16"PRIx64" from old id %.16"PRIx64,
urlString, idNbr, oldIDNbr];
[self unregisterURLWithID: oldIDNbr];
[self registerURL: urlString
withID: idNbr];
rc = YES;
}
return rc;
}
- (BOOL) registerURL: (NSString *) urlString - (BOOL) registerURL: (NSString *) urlString
withID: (uint64_t) idNbr withID: (uint64_t) idNbr
{ {
NSString *oldURL; NSString *oldURL;
uint64_t oldIdNbr; uint64_t oldIdNbr;
bool rc, softDeleted; bool softDeleted;
oldURL = [self urlFromID: idNbr]; oldURL = [self urlFromID: idNbr];
if (oldURL != NULL) if (oldURL != NULL)
@ -257,7 +277,6 @@ MAPIStoreMappingKeyFromId (uint64_t idNbr)
} }
else else
{ {
rc = YES;
// [self logWithFormat: @"registered url '%@' with id %lld (0x%.16"PRIx64")", // [self logWithFormat: @"registered url '%@' with id %lld (0x%.16"PRIx64")",
// urlString, idNbr, idNbr]; // urlString, idNbr, idNbr];
@ -266,7 +285,7 @@ MAPIStoreMappingKeyFromId (uint64_t idNbr)
idNbr, [urlString UTF8String]); idNbr, [urlString UTF8String]);
} }
return rc; return YES;
} }
- (void) registerURLs: (NSArray *) urlStrings - (void) registerURLs: (NSArray *) urlStrings