[Imap-protocol] Concurrent flag changes
alexey.melnikov at isode.com
Thu May 3 03:47:13 PDT 2012
On 2 May 2012, at 22:28, Timo Sirainen <tss at iki.fi> wrote:
> I don't think IMAP RFCs actually require any specific behavior for this, so this is more of a "any recommendations?" type of a question:
> Clients C1 and C2 send:
> C1: a FETCH 1 FLAGS
> S1: * 1 FETCH (FLAGS (\Seen \Answered))
> S1: a OK
> C2: b STORE 1 +FLAGS (\Flagged)
> S2: * 1 FETCH (FLAGS (\Seen \Flagged))
> S2: b OK
> At this point C1 still thinks that 1's flags are (\Seen), and being a little bit stupid it unsets the \Seen flag by sending:
> C1: c STORE 1 FLAGS (\Answered)
> Now, I think the possible replies are either of these:
> S1: * 1 FETCH (FLAGS (\Answered))
> S1: * 1 FETCH (FLAGS (\Answered \Flagged))
> Dovecot currently sends the first reply, but I've started thinking that perhaps I should change it to the second one. The question is really: Should STORE FLAGS be thought of as
> a) Reset all the flags that you have currently, whatever they are, and only set these flags.
If you want to prevent conflicts above, you need to use CONDSTORE.
> b) Atomically add these flags I've listed, and remove those that I used to see previously in this session but aren't listed here.
> In the case of actual IMAP clients doing this, this is probably almost irrelevant. But it becomes more relevant if you have two IMAP servers doing a 2-way mailbox synchronization after a possibly long disconnection, and the same message's flags are changed in both of them.
Don't use STORE FLAGS when synchronizing servers ;). I don't.
> I haven't really looked at how many of the real world clients are using STORE FLAGS. For those I'd think b) is what they really intend to do. But are there perhaps some specialized clients
More information about the Imap-protocol