From 6b0a11445488a3b5c34414bbada6292871b56371 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 14 Sep 2011 20:05:09 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: 0ffde732abb09a8e3d0382ed47a3ec787f25796e Monotone-Revision: 3d7f4c315141a708ca8e3535fb0792843e1b8f9a Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2011-09-14T20:05:09 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 +++++- SoObjects/Mailer/SOGoMailFolder.h | 6 +++--- SoObjects/Mailer/SOGoMailFolder.m | 19 +++++++++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 247b3f406..d8e11f8ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,7 +20,11 @@ * OpenChange/MAPIStoreFolder.m: (getPrAccess:inMemCtx:) fixed permissions issue - we were returning a wrong value leading to IMAP subfolders not being "writable" - + + * SoObject/Mailer/SOGoMailFolder.m (prefetchCoreInfosForMessageKeys:) + Fixed a MAJOR issue regarding keys handling. We should NEVER assume + the untagged IMAP response's order will be the same as the FETCH's one! + 2011-09-04 Ludovic Marcotte * OpenChange/MAPIStoreMapping.m: (MAPIStoreMappingTDBTraverse()) diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index 798e69163..bd23afbeb 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -2,14 +2,14 @@ Copyright (C) 2009-2011 Inverse inc. Copyright (C) 2004-2005 SKYRIX Software AG - This file is part of OpenGroupware.org. + This file is part of SOGo - OGo is free software; you can redistribute it and/or modify it under + SOGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - OGo is distributed in the hope that it will be useful, but WITHOUT ANY + SOGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 9c96fe883..d64a82cdc 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -270,9 +270,10 @@ static NSString *defaultUserID = @"anyone"; /* messages */ - (void) prefetchCoreInfosForMessageKeys: (NSArray *) keys { - NSDictionary *infos; - NSMutableArray *uids; NSUInteger count, max, keyLength; + NSMutableArray *uids; + NSDictionary *infos; + NSArray *allValues; NSString *key; if (!SOGoMailCoreInfoKeys) @@ -301,8 +302,18 @@ static NSString *defaultUserID = @"anyone"; infos = (NSDictionary *) [self fetchUIDs: uids parts: SOGoMailCoreInfoKeys]; prefetchedInfos = [[NSMutableDictionary alloc] initWithCapacity: max]; - [prefetchedInfos setObjects: [infos objectForKey: @"fetch"] - forKeys: uids]; + + // We MUST NOT use setObjects:forKeys here as the fetch's array does NOT + // necessarily have the same order! + allValues = [infos objectForKey: @"fetch"]; + max = [allValues count]; + + for (count = 0; count < max ; count++) + { + infos = [allValues objectAtIndex: count]; + [prefetchedInfos setObject: infos + forKey: [infos objectForKey: @"uid"]]; + } } else prefetchedInfos = nil;