MBOX-Line: From robm at fastmail.fm  Sun Jun  5 17:20:59 2011
To: imap-protocol@u.washington.edu
From: Robert Mueller <robm@fastmail.fm>
Date: Fri Jun  8 12:34:46 2018
Subject: [Imap-protocol] Where to start?
In-Reply-To: <4DEBDFF5.9000301@BusCom.net>
References: <4DEBB242.2090200@BusCom.net><4DEBB58D.3090101@logicprobe.org>
	<4DEBBAB3.2030301@BusCom.net><4DEBBEC1.3080600@BusCom.net><201106051924.p55JOwpG003543@mxout12.cac.washington.edu>
	<4DEBDFF5.9000301@BusCom.net>
Message-ID: <1307319659.7961.1459831005@webmail.messagingengine.com>

> > 4). Decide what data to keep in memory for each message in an open
> >   mailbox.  (By "open", I mean one for which a session is in
> >   progress, that is opened as the result of a SELECT or EXAMINE
> >   command.)  A likely minimum would be UID, IMAP message flags,
> >   message size and, of course, a reference to the message itself.  I
> >   am assuming that this information is indexed by message number and
> >   hence that that is not explicitly stored.  You may find reason to
> >   add more data such as a flag indicating if the message is matched
> >   in a current SEARCH.

One thing that can be tricky if you don't design it in up front is the
way you end up with multiple message list views if you have multiple
clients connected.

---
5.5.    Multiple Commands in Progress
...
   A non-obvious ambiguity occurs with commands that permit an untagged
   EXPUNGE response (commands other than FETCH, STORE, and SEARCH),
   since an untagged EXPUNGE response can invalidate sequence numbers in
   a subsequent command.  This is not a problem for FETCH, STORE, or
   SEARCH commands because servers are prohibited from sending EXPUNGE
   responses while any of those commands are in progress.
---

So one client might delete + expunge a message, but another connection
won't see that expunge until they do a command that allows it to be
seen. This can significantly affect how you design your internal state
management, namely that when you expunge a message, you probably just
want to mark it as expunged on disk and actually cleanup later, rather
than removing it immediately from your mailbox state. This is useful
longer term for things like QRESYNC as well.

I'm sure Bron (cc'd) can make some comments on this as well, given the
significant changes he made to cyrus to make this work correctly.

Rob

