From bd6edc2243b91b8ec58006f4a134eb347b8c8e24 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 15 Jan 2010 12:19:36 +0000 Subject: [PATCH] Monotone-Parent: f41b9f8e61926cdfbebea33229cefdf60f2fdbcb Monotone-Revision: fb65b0d0f170c30fcadecf001ad33a8fc79e9e89 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-01-15T12:19:36 Monotone-Branch: ca.inverse.sogo --- SOPE/sope-patchset-r1664.diff | 44 ++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/SOPE/sope-patchset-r1664.diff b/SOPE/sope-patchset-r1664.diff index 50a8d2b21..7794ee950 100644 --- a/SOPE/sope-patchset-r1664.diff +++ b/SOPE/sope-patchset-r1664.diff @@ -1345,20 +1345,23 @@ Index: sope-mime/NGImap4/NGImap4Connection.m if (![[result valueForKey:@"result"] boolValue]) { return [self errorForResult:result text:@"Failed to change flags of IMAP4 message"]; -@@ -737,20 +770,21 @@ +@@ -737,34 +770,42 @@ - (BOOL)doesMailboxExistAtURL:(NSURL *)_url { NSString *folderName; + NSArray *caches; id result; + int count, max; ++ BOOL found; ++ found = NO; ++ /* check in hierarchy cache */ - - if ((result = [self cachedHierarchyResults]) != nil) { + caches = [self->subfolders allValues]; + max = [caches count]; -+ for (count = 0; count < max; count++) { ++ for (count = 0; !found && count < max; count++) { NSString *p; - - result = [(NSDictionary *)result objectForKey:@"list"]; @@ -1372,25 +1375,36 @@ Index: sope-mime/NGImap4/NGImap4Connection.m -#endif if ([p hasSuffix:@"/"]) p = [p substringToIndex:[p length]-1]; - return ([(NSDictionary *)result objectForKey:p] != nil) ? YES : NO; -@@ -760,11 +794,11 @@ - // TODO: we should probably just fetch the whole hierarchy? +- return ([(NSDictionary *)result objectForKey:p] != nil) ? YES : NO; ++ found = ([(NSDictionary *)result objectForKey:p] != nil); + } ++ ++ if (!found) { ++ /* check using IMAP4 select */ ++ // TODO: we should probably just fetch the whole hierarchy? - folderName = [self imap4FolderNameForURL:_url]; +- /* check using IMAP4 select */ +- // TODO: we should probably just fetch the whole hierarchy? +- +- folderName = [self imap4FolderNameForURL:_url]; - result = [[self client] select:folderName]; - if (![[result valueForKey:@"result"] boolValue]) - return NO; - - return YES; ++ folderName = [self imap4FolderNameForURL:_url]; + -+ result = [self->client status: folderName -+ flags: [NSArray arrayWithObject: @"UIDVALIDITY"]]; ++ result = [self->client status: folderName ++ flags: [NSArray arrayWithObject: @"UIDVALIDITY"]]; + -+ return ([[result valueForKey: @"result"] boolValue]); ++ found =([[result valueForKey: @"result"] boolValue]); ++ } ++ ++ return found; } - (id)infoForMailboxAtURL:(NSURL *)_url { -@@ -789,7 +823,8 @@ +@@ -789,7 +830,8 @@ /* construct path */ newPath = [self imap4FolderNameForURL:_url]; @@ -2399,7 +2413,15 @@ Index: sope-mime/NGImap4/ChangeLog =================================================================== --- sope-mime/NGImap4/ChangeLog (revision 1664) +++ sope-mime/NGImap4/ChangeLog (working copy) -@@ -1,3 +1,99 @@ +@@ -1,3 +1,107 @@ ++2010-01-15 Wolfgang Sourdeau ++ ++ * NGImap4Connection.m (-doesMailboxExistAtURL:): sometimes an ++ entry is present in the subfolders cache. When it is the case, the ++ method was returning at the end of the first iteration even though ++ the mailbox was never found. We need to continue and then proceed ++ to the "status" check whether the cache is populated or not. ++ +2010-01-14 Wolfgang Sourdeau + + * NGImap4Connection.m (-doesMailboxExistAtURL:): mailbox paths can