diff --git a/ChangeLog b/ChangeLog index 204c593c8..bc7c53d97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,3 @@ -2011-10-07 Wolfgang Sourdeau - - * OpenChange/MAPIStoreMailFolder.m (-synchroniseCache) - (-getDeletedKeysFromChangeNumber:andCN:inTableType:): attempt to - fix the leak of version numbers. - 2011-10-07 Francis Lachapelle * UI/WebServerResources/UIxPreferences.js diff --git a/OpenChange/MAPIStoreMailFolder.m b/OpenChange/MAPIStoreMailFolder.m index cedc8d503..1de4bfe69 100644 --- a/OpenChange/MAPIStoreMailFolder.m +++ b/OpenChange/MAPIStoreMailFolder.m @@ -469,8 +469,7 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) { BOOL rc = YES; uint64_t newChangeNum; - NSNumber *ti, *changeNumber, *modseq, *lastModseq, *nextModseq, - *lastDeletedModseq, *uid; + NSNumber *ti, *changeNumber, *modseq, *lastModseq, *nextModseq, *uid; uint64_t lastModseqNbr; EOQualifier *searchQualifier; NSArray *uids; @@ -567,22 +566,16 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) ldb_transaction_commit([[self context] connectionInfo]->oc_ctx); foundChange = YES; - [currentProperties setObject: lastModseq forKey: @"SyncLastModseq"]; } - lastDeletedModseq - = [currentProperties objectForKey: @"SyncLastDeletedModseq"]; - if (lastDeletedModseq) + if (lastModseq) { - lastModseqNbr = [lastDeletedModseq unsignedLongLongValue]; - uids = [(SOGoMailFolder *) sogoObject - fetchUIDsOfVanishedItems: lastModseqNbr]; - if ([uids count] > 0) - { - foundChange = YES; - [currentProperties setObject: uids - forKey: @"SyncLastDeletedUIDs"]; - } + /* FIXME: the problem here is that if a delete is the last operation + performed on a folder, the SyncLastSynchronisationDate will continuously + get updated until a new modseq shows up */ + foundChange |= [[(SOGoMailFolder *) sogoObject + fetchUIDsOfVanishedItems: lastModseqNbr] + count] > 0; } if (foundChange) @@ -590,6 +583,7 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) ti = [NSNumber numberWithDouble: [now timeIntervalSince1970]]; [currentProperties setObject: ti forKey: @"SyncLastSynchronisationDate"]; + [currentProperties setObject: lastModseq forKey: @"SyncLastModseq"]; [versionsMessage appendProperties: currentProperties]; [versionsMessage save]; } @@ -732,7 +726,8 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) NSArray *deletedKeys, *deletedUIDs; NSNumber *changeNumNbr; uint64_t modseq; - NSMutableDictionary *currentProperties, *messages; + NSDictionary *versionProperties; // , *status; + NSMutableDictionary *messages, *mapping; NSNumber *newChangeNumNbr; // , *highestModseq; uint64_t newChangeNum; NSUInteger count, max; @@ -744,25 +739,28 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) unsignedLongLongValue]; if (modseq > 0) { - currentProperties = [[versionsMessage properties] mutableCopy]; - deletedUIDs = [currentProperties objectForKey: @"SyncLastDeletedUIDs"]; - if ([deletedUIDs count] > 0) + // status + // = [sogoObject + // statusForFlags: [NSArray arrayWithObject: @"HIGHESTMODSEQ"]]; + // highestModseq = [status objectForKey: @"highestmodseq"]; + + versionProperties = [versionsMessage properties]; + messages = [versionProperties objectForKey: @"Messages"]; + deletedUIDs = [(SOGoMailFolder *) sogoObject + fetchUIDsOfVanishedItems: modseq]; + deletedKeys = [deletedUIDs stringsWithFormat: @"%@.eml"]; + max = [deletedUIDs count]; + if (max > 0) { - [currentProperties removeObjectForKey: @"SyncLastDeletedUIDs"]; - [currentProperties setObject: changeNumNbr - forKey: @"SyncLastDeletedModseq"]; - messages = [currentProperties objectForKey: @"Messages"]; [messages removeObjectsForKeys: deletedUIDs]; - [versionsMessage appendProperties: currentProperties]; - [versionsMessage save]; - - deletedKeys = [deletedUIDs stringsWithFormat: @"%@.eml"]; - max = [deletedKeys count]; + mapping = [versionProperties objectForKey: @"VersionsMapping"]; for (count = 0; count < max; count++) newChangeNum = [[self context] getNewChangeNumber]; newChangeNumNbr = [NSNumber numberWithUnsignedLongLong: newChangeNum]; *cnNbr = newChangeNumNbr; + [mapping setObject: newChangeNumNbr forKey: @"SyncLastModseq"]; + [versionsMessage save]; } } else