[PATCH] Re: Don't cache empty IMAP folders

Nicolas Sebrecht nicolas.s-dev at laposte.net
Wed Sep 7 18:19:21 BST 2011


On Wed, Sep 07, 2011 at 03:23:28PM +0200, Sebastian Spaeth wrote:
> If a folder is empty, most servers will return EXISTS 0 and imaplib2
> passes back ['0'] as return value to a select(). It returns [None] if
> no EXISTS response was given by the server at all.
> 
> Attempting to fetch the UIDs of 0 emails which leads to
> various error messages (One server responds with "NO No matching
> messages", Gmail seems to say "BAD Bad message sequence 1:*" for some
> (although it is working fine for me with Gmail, so it might behave
> different for different people).
> 
> In case we get an None or 0 back, we simply stop caching messages as the
> folder is empty. This should fix the various error reports that have
> popped up.
> 
> Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
> ---
> I was able to test this with a Gmail account. This should fix both the 
> "NO No matching messages" and the BAD Bad message sequence errors that
> people are seeing on empty folders. Unfortunately my mail server had 
> never shown me errors, and my Gmail account did not send any error 
> message either. This fix should be good and fine in any case.

Thank you much.

-- 
Nicolas Sebrecht




More information about the OfflineIMAP-project mailing list