MBOX-Line: From slusarz at curecanti.org  Mon Jan 28 13:58:43 2013
To: imap-protocol@u.washington.edu
From: Michael M Slusarz <slusarz@curecanti.org>
Date: Fri Jun  8 12:34:50 2018
Subject: [Imap-protocol] Re: Courier bug(?)
In-Reply-To: <9ade1aaa-6d67-443b-8fa3-43f00486d4cb@flaska.net>
References: <20130121144822.Horde.kbr5Y8IKwMlD1fH1Qun9hQ1@bigworm.curecanti.org>
	<CAKHUCzwJ8xq7O8vGDHe0D9Jviac06o-QtePMhKYV7HzwzRPMPA@mail.gmail.com>
	<1358846428.12608.2.camel@hurina>
	<CAC4RtVAobTOjLdLH++_qp=HCtdZJne5Q7TUF_P=9J6a+gg2fmQ@mail.gmail.com>
	<51015F8D.8020300@isode.com>
	<9ade1aaa-6d67-443b-8fa3-43f00486d4cb@flaska.net>
Message-ID: <20130128145843.Horde._nr6MiWpMYirI_cZr53iQQ8@bigworm.curecanti.org>

Quoting Jan Kundr?t <jkt@flaska.net>:

> As far as I understand all of the RFCs, there is unfortunately  
> nothing but the 5162's errata which would guarantee that unsolicited  
> FETCH responses will have UIDs in them. Based on that observation, I  
> claim that a client which wants to keep track of updates to  
> messages' flags will have to keep a full mapping of the seq->UID for  
> the relevant message ranges at all times. Remember, servers are free  
> to send the data at any time, not just when fetching body parts.

I agree with the former part of your statement.  But I think the  
latter part of your statement is overstating the issue.

While there is nothing in the specs that guarantees that FETCH  
responses will have UIDs, the actual reality, at least as it stands  
right now, is that any decent IMAP server *DOES* return this UID  
information.  E.g. both Cyrus and Dovecot are guaranteed to return  
UIDs with unsolicited FETCH responses if CONDSTORE/QRESYNC is active.   
Hopefully the Gmail folks are doing the same thing with their  
CONDSTORE/QRESYNC implementation.

IMHO, a more sensible approach for a disconnected client, rather than  
trying to keep a sequence->UID map (ugh), is to assume that these  
unsolicited FETCH responses *will* always have UID information  
associated with it, which in current practice will happen almost 100%  
of the time. A client can then have code to check for the following  
occurrence during a command:

1. At least 1 FLAGS item was returned.
2. The item in #1 cannot be correlated with a UID with the other FETCH  
data returned during the current command.
3. The highest MODSEQ value increased.

Only if these 3 items occur does a client need some other way of  
linking the flag changes with an UID.  Since this event should occur  
only extremely rarely, if at all, one appropriate way of correctly  
syncing the local cache would be to:

1. Ignore the returned FETCH information for local caching purposes.
2. Immediately reopen the mailbox.  (The client's existing  
CONDSTORE/QRESYNC will ensure that the mailbox is correctly sync'd).

michael


