mailing list archives

meli community discussions

⚠️ if something does not work as intended when interracting with the mailing lists,
reach out Github mirror Gitea repo @epilys:matrix.org

E-mail headers
From: Jan Kundrát <jkt@flaska.net>
To: imap-protocol@u.washington.edu
Date: Fri, 08 Jun 2018 12:34:48 -0000
Message-ID: 4FD221F9.8090601@flaska.net permalink / raw / eml / mbox
Hi,
a big part of this mail is probably answered in RFC5162's errata, but
I'd still like someone to explicitly confirm that how I understand this
thing is correct.

I'm afraid I have a possible race condition in my code which keeps
mailbox up to date with server's responses. Right now, my code supports
CONDSTORE but not QRESYNC. The following bits describe how it behaves
after the mailbox has been "synced", ie. when my idea about UID -> seq
mapping matches with the state on server.

In this situation, whenever the program needs to perform something (like
send the LIST command, issue a FETCH for some body part, store some
flags through UID STORE etc), the command will be sent to the IMAP
server almost immediately, and this can in turn trigger many interesting
responses like EXISTS or EXPUNGE. That's why I'm ready to process them
at any point, no matter if there's a command in progress or not. I
believe that I'm handling them correctly now:

- Whenever I receive EXISTS >= current number of messages, I simply add
the correct number of "empty messages" with UID zero to the end of my
UID -> seq mapping and to some internal data structure which is in turn
shown to the user who will see a few "Loading..." placeholders. I also
immediately queue a UID FETCH previous_uidnext:* FLAGS command. The goal
is that the UID number will eventually arrive and when they arrive, I
update my on-disk cache with the obtained data.

- When EXPUNGE arrives, I check the number for correctness (1 <= number
< mailbox_size) and remove the message which is at that particular
index. If its UID was not zero, I also remove any data associated with
that UID from my on-disk cache. If the number was zero, well, the idea
is that this shouldn't matter at all as I couldn't possibly have any
useful data for that message in my cache (message parts, envelopes and
body structure are fetched only after the UID is known).

I'm not sure how to deal with it if I enable QRESYNC, though. The spec
says that I should be ready for both EXPUNGE and VANISHED. I'd like to
leave my handling of EXPUNGE unchanged if possible, which means that I
really have to create and insert the fake UID-0 messages immediately in
response to increased EXISTS.

The problem is what shall I do when I get VANISHED with a UID which is
bigger than the highest UID I already know? (Like if a message arrived
and before I had a chance to ask for its UID, it gets removed through
VANISHED.) At this point it looks like I can just pick any of the still
unknown messages in my in-memory state and delete one of them for each
high UID received in the VANISHED response. I'm a bit nervous about that
approach, though -- consider the following situation (which is partially
answered by the QRESYNC errata):

(Mailbox contains one message with UID 5; UIDNEXT is 11, everything is
synced.)

S: * 12 EXISTS
C: x UID FETCH 11:* (FLAGS)

(At this point, server sends unsolicited data like FLAGS or even
BODYSTRUCTURE for the new arrivals. I believe that it's allowed to do so
per RFC3501.)

S: * 2 FETCH (FLAGS (a) BODYSTRUCTURE ...)
S: * 3 FETCH (FLAGS (b) ENVELOPE ...)

(I'm on a slow network, so even before my UID FETCH arrives to the
server, one of these messages is gone and the server sends back VANISHED:)

S: * VANISHED 11

(The programmer has flipped a coin and hence the code always deletes the
very last message with UID=0. That means that the message flagged "b" is
gone and "a" remains.)

S: * 2 FETCH (FLAGS (b) UID 12)

(At this point, client finally gets the UID for the only remaining
message with UID=0, along with flags. The bad thing is that user has
already seen a stub message flagged as "a" while in fact there was just
the "b" one.)

After reading the errata, I realize that servers are discouraged from
not sending UIDs in FETCH responses when QRESYNC has been enabled. Would
it be reasonable for my client to always ignore FETCH updates which do
not contain UID when QRESYNC is in effect? (I can easily change my code
to never issue a FETCH, always UID FETCH with QRESYNC.)

My biggest concern is that my code perform potentially intrusive actions
(like allocating complex structures for BODYSTRUCTURE and actually
showing them to the user) upon seeing the FETCH responses for a given
message for the first time. When I receive interleaved VANISHED and
FETCH-without-UID responses, the result could be confusing to the user
(and given that I already have an application where the messages are
pushed into an external DB as soon as they arrive, I can imagine a use
case where people would want to store only messages with a particular
flag -- again, the code would get confused in the situation I described
above.)

It seems to me that if the QRESYNC extension introduced new * ARRIVED
<uid-sequence-set> response to replace EXISTS in a similar way that
VANISHED replaces EXPUNGE, the window where client knows about new
arrivals but doesn't know about the UIDs would cease to exist. Is there
a particular reason why QRESYNC is not modeled in that way?

Finally, my last question is why does QRESYNC require me to issue an
ENABLE QRESYNC at all? I feel like the SELECT ... QRESYNC should be
enough to tell the server that I'm really expecting the VANISHED
responses. My biggest issue with ENABLE is that (at least according to
the last errata by Alfred Hoenes from 2008-03-11 which is "held for
document update") I'm supposed to wait for untagged ENABLED before
issuing SELECT ... QRESYNC which introduces another roundtrip to the
connection process. I'm ignoring this requirement for now, so I'll
happily pipeline ENABLE QRESYNC with SELECT ... QRESYNC and hope that I
won't get BAD in response from some pedantic server. I'd love to get
some comments on this as well.

With kind regards,
Jan

-- 
Trojita, a fast e-mail client -- http://trojita.flaska.net/



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 270 bytes
Desc: OpenPGP digital signature
URL: <http://mailman13.u.washington.edu/pipermail/imap-protocol/attachments/20120608/58e8e3b8/attachment.sig>
Reply
E-mail headers
From: jkt@flaska.net
To: imap-protocol@localhost
Date: Fri, 08 Jun 2018 12:34:48 -0000
Message-ID: 4FD4EB4B.7050000@flaska.net permalink / raw / eml / mbox
I'm afraid I've found another possible issue with QRESYNC. The RFC5162
is pretty clear that servers SHOULD inform only about those UIDs which
are expunged "right now" through the VANISHED response. Unless I'm
terribly mistaken, it means that a client has to handle VANISHED
responses which refer to UIDs which were expunged a long time ago, and
servers *can* send them and still be called compliant.

I believe that this brings a few issues in the following scenario (where
mailbox contains one message with UID 5; UIDNEXT is 11, everything is
synced):

S: * 3 EXISTS
S: * VANISHED 12:20

The server is telling me that any UIDs between 12 and 20 are gone. The
problem is that I don't know whether any message has got this UID, ie.
whether the messages #2 and #3 (the first and second arrivals) fall into
that range. What shall a compliant IMAP client do at this point? Shall I
remove any messages upon receiving the VANISHED response? Shall I send a
UID SEARCH command to find out what new messages are really there?
That'd complicate my code quite a lot, unfortunately.

Even more entertaining would be an interaction where the server
occasionally sent a regular EXPUNGED instead of VANISHED (it's allowed
to do so per RFC 5162); that'd lead to an interesting mix of unknowns
about a mailbox' state...

I'm looking forward to answers about this matter.

With kind regards,
Jan

-- 
Trojita, a fast e-mail client -- http://trojita.flaska.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 270 bytes
Desc: OpenPGP digital signature
URL: <http://mailman13.u.washington.edu/pipermail/imap-protocol/attachments/20120610/3a8d4dd1/attachment.sig>
Reply
E-mail headers
From: jkt@flaska.net
To: imap-protocol@localhost
Date: Fri, 08 Jun 2018 12:34:48 -0000
Message-ID: 50059CCA.6030404@flaska.net permalink / raw / eml / mbox
On 06/08/12 18:02, Jan Kundr?t wrote:
> Finally, my last question is why does QRESYNC require me to issue an
> ENABLE QRESYNC at all? I feel like the SELECT ... QRESYNC should be
> enough to tell the server that I'm really expecting the VANISHED
> responses.

I think I have found an answer to this -- if the client doesn't have any 
cached state for a particular mailbox, it cannot really SELECT QRESYNC that.

If it tried to use a HIGHESTMODSEQ = 1, it would risk an enormous amount 
of data being transferred in VANISHED EARLIER as the server would have 
to inform about each and every expunge which has happened in the mailbox 
since its creation. This is due to the known-uids ABNF item format which 
doesn't provide any way of sending "nope, I don't know about any UIDs" 
-- the list can either be missing, or contain at least one item.

If I understand everything correctly, ENABLE QRESYNC is therefore still 
required as long as one wants to receive VANISHED instead of EXPUNGE. My 
apologies for assuming that it's useless :).

Also is probably means that a QRESYNC-capable clients have to use SELECT 
... CONDSTORE when they open a mailbox for the first time.

I'd appreciate if someone could verify these assumptions -- they look 
plausible to me, but I didn't see any flaw in my previous reasoning, 
either :).

With kind regards
Jan

-- 
Trojita, a fast e-mail client -- http://trojita.flaska.net/
Reply
E-mail headers
From: alexey.melnikov@isode.com
To: imap-protocol@localhost
Date: Fri, 08 Jun 2018 12:34:48 -0000
Message-ID: 15B1C62B-9221-4A65-94FA-4FADF1616551@isode.com permalink / raw / eml / mbox
Hi Jan,

On 8 Jun 2012, at 17:02, Jan Kundr?t <jkt@flaska.net> wrote:

> Hi,
> a big part of this mail is probably answered in RFC5162's errata, but
> I'd still like someone to explicitly confirm that how I understand this
> thing is correct.
> 
> I'm afraid I have a possible race condition in my code which keeps
> mailbox up to date with server's responses. Right now, my code supports
> CONDSTORE but not QRESYNC. The following bits describe how it behaves
> after the mailbox has been "synced", ie. when my idea about UID -> seq
> mapping matches with the state on server.
> 
> In this situation, whenever the program needs to perform something (like
> send the LIST command, issue a FETCH for some body part, store some
> flags through UID STORE etc), the command will be sent to the IMAP
> server almost immediately, and this can in turn trigger many interesting
> responses like EXISTS or EXPUNGE. That's why I'm ready to process them
> at any point, no matter if there's a command in progress or not. I
> believe that I'm handling them correctly now:
> 
> - Whenever I receive EXISTS >= current number of messages, I simply add
> the correct number of "empty messages" with UID zero to the end of my
> UID -> seq mapping and to some internal data structure which is in turn
> shown to the user who will see a few "Loading..." placeholders. I also
> immediately queue a UID FETCH previous_uidnext:* FLAGS command. The goal
> is that the UID number will eventually arrive and when they arrive, I
> update my on-disk cache with the obtained data.
> 
> - When EXPUNGE arrives, I check the number for correctness (1 <= number
> < mailbox_size) and remove the message which is at that particular
> index. If its UID was not zero, I also remove any data associated with
> that UID from my on-disk cache. If the number was zero, well, the idea
> is that this shouldn't matter at all as I couldn't possibly have any
> useful data for that message in my cache (message parts, envelopes and
> body structure are fetched only after the UID is known).
> 
> I'm not sure how to deal with it if I enable QRESYNC, though. The spec
> says that I should be ready for both EXPUNGE and VANISHED. I'd like to
> leave my handling of EXPUNGE unchanged if possible, which means that I
> really have to create and insert the fake UID-0 messages immediately in
> response to increased EXISTS.
> 
> The problem is what shall I do when I get VANISHED with a UID which is
> bigger than the highest UID I already know? (Like if a message arrived
> and before I had a chance to ask for its UID, it gets removed through
> VANISHED.) At this point it looks like I can just pick any of the still
> unknown messages in my in-memory state and delete one of them for each
> high UID received in the VANISHED response. I'm a bit nervous about that
> approach, though -- consider the following situation (which is partially
> answered by the QRESYNC errata):
> 
> (Mailbox contains one message with UID 5; UIDNEXT is 11, everything is
> synced.)
> 
> S: * 12 EXISTS
> C: x UID FETCH 11:* (FLAGS)
> 
> (At this point, server sends unsolicited data like FLAGS or even
> BODYSTRUCTURE for the new arrivals. I believe that it's allowed to do so
> per RFC3501.)
> 
> S: * 2 FETCH (FLAGS (a) BODYSTRUCTURE ...)
> S: * 3 FETCH (FLAGS (b) ENVELOPE ...)
> 
> (I'm on a slow network, so even before my UID FETCH arrives to the
> server, one of these messages is gone and the server sends back VANISHED:)
> 
> S: * VANISHED 11
> 
> (The programmer has flipped a coin and hence the code always deletes the
> very last message with UID=0. That means that the message flagged "b" is
> gone and "a" remains.)
> 
> S: * 2 FETCH (FLAGS (b) UID 12)
> 
> (At this point, client finally gets the UID for the only remaining
> message with UID=0, along with flags. The bad thing is that user has
> already seen a stub message flagged as "a" while in fact there was just
> the "b" one.)

Right, guessing which of the yet unknown to your client messages got expunged doesn't look right.
> 
> After reading the errata, I realize that servers are discouraged from
> not sending UIDs in FETCH responses when QRESYNC has been enabled. Would
> it be reasonable for my client to always ignore FETCH updates which do
> not contain UID when QRESYNC is in effect?

Yes.

> (I can easily change my code
> to never issue a FETCH, always UID FETCH with QRESYNC.)

Good idea.

> 
> My biggest concern is that my code perform potentially intrusive actions
> (like allocating complex structures for BODYSTRUCTURE and actually
> showing them to the user) upon seeing the FETCH responses for a given
> message for the first time. When I receive interleaved VANISHED and
> FETCH-without-UID responses, the result could be confusing to the user
> (and given that I already have an application where the messages are
> pushed into an external DB as soon as they arrive, I can imagine a use
> case where people would want to store only messages with a particular
> flag -- again, the code would get confused in the situation I described
> above.)

It looks like your code should get smarter if you don't want to just ignore FETCH responses with no UIDs. 

> 
> It seems to me that if the QRESYNC extension introduced new * ARRIVED
> <uid-sequence-set> response to replace EXISTS in a similar way that
> VANISHED replaces EXPUNGE, the window where client knows about new
> arrivals but doesn't know about the UIDs would cease to exist. Is there
> a particular reason why QRESYNC is not modeled in that way?

The idea didn't' occur at the time of writing the QRESYNC spec :).
> 
> Finally, my last question is why does QRESYNC require me to issue an
> ENABLE QRESYNC at all? I feel like the SELECT ... QRESYNC should be
> enough to tell the server that I'm really expecting the VANISHED
> responses. My biggest issue with ENABLE is that (at least according to
> the last errata by Alfred Hoenes from 2008-03-11 which is "held for
> document update") I'm supposed to wait for untagged ENABLED before
> issuing SELECT ... QRESYNC which introduces another roundtrip to the
> connection process. I'm ignoring this requirement for now, so I'll
> happily pipeline ENABLE QRESYNC with SELECT ... QRESYNC and hope that I
> won't get BAD in response from some pedantic server. I'd love to get
> some comments on this as well.

ENABLE QRESYNC failing should be a rare event, so doing the optimization you do seems to be Ok, as long as you can handle the BAD response.

Best Regards,
Alexey
Reply
E-mail headers
From: alexey.melnikov@isode.com
To: imap-protocol@localhost
Date: Fri, 08 Jun 2018 12:34:48 -0000
Message-ID: E96EC1B2-A6D2-4BF6-9004-8248F61015F5@isode.com permalink / raw / eml / mbox
Hi Jan,

On 10 Jun 2012, at 19:45, Jan Kundr?t <jkt@flaska.net> wrote:

> I'm afraid I've found another possible issue with QRESYNC. The RFC5162
> is pretty clear that servers SHOULD inform only about those UIDs which
> are expunged "right now" through the VANISHED response. Unless I'm
> terribly mistaken, it means that a client has to handle VANISHED
> responses which refer to UIDs which were expunged a long time ago, and
> servers *can* send them and still be called compliant.
> 
> I believe that this brings a few issues in the following scenario (where
> mailbox contains one message with UID 5; UIDNEXT is 11, everything is
> synced):
> 
> S: * 3 EXISTS
> S: * VANISHED 12:20
> 
> The server is telling me that any UIDs between 12 and 20 are gone. The
> problem is that I don't know whether any message has got this UID, ie.
> whether the messages #2 and #3 (the first and second arrivals) fall into
> that range. What shall a compliant IMAP client do at this point?

It depends :)

> Shall I
> remove any messages upon receiving the VANISHED response? Shall I send a
> UID SEARCH command to find out what new messages are really there?
> That'd complicate my code quite a lot, unfortunately.

In most cases you don't need to do anything. For example if you only cached a part of the mailbox (e.g. N most recent messages), and UIDs listed in VANISHED are below any UID you know about, then you don't really care about removed messages.

It might make a difference if you want to display the number of messages in the mailbox or use message numbers for some operations. If you cached the whole mailbox, then you know the whole msgno-to-UID map. If you only cached a part, then maybe doing something like "UID FETCH *" (or a similar SEARCH) would help.

> Even more entertaining would be an interaction where the server
> occasionally sent a regular EXPUNGED instead of VANISHED (it's allowed
> to do so per RFC 5162); that'd lead to an interesting mix of unknowns
> about a mailbox' state...

I hope no server does that (unless in different sessions, when QRESYNC is enabled in one and not another...).
> 
> I'm looking forward to answers about this matter.

Best Regards,
Alexey
Reply
E-mail headers
From: alexey.melnikov@isode.com
To: imap-protocol@localhost
Date: Fri, 08 Jun 2018 12:34:48 -0000
Message-ID: 5005A717.7050805@isode.com permalink / raw / eml / mbox
Hi Jan,

On 17/07/2012 18:11, Jan Kundr?t wrote:
> On 06/08/12 18:02, Jan Kundr?t wrote:
>> Finally, my last question is why does QRESYNC require me to issue an
>> ENABLE QRESYNC at all? I feel like the SELECT ... QRESYNC should be
>> enough to tell the server that I'm really expecting the VANISHED
>> responses.
>
> I think I have found an answer to this -- if the client doesn't have 
> any cached state for a particular mailbox, it cannot really SELECT 
> QRESYNC that.

Right.

> If it tried to use a HIGHESTMODSEQ = 1, it would risk an enormous 
> amount of data being transferred in VANISHED EARLIER as the server 
> would have to inform about each and every expunge which has happened 
> in the mailbox since its creation. This is due to the known-uids ABNF 
> item format which doesn't provide any way of sending "nope, I don't 
> know about any UIDs" -- the list can either be missing, or contain at 
> least one item.

Yes.

> If I understand everything correctly, ENABLE QRESYNC is therefore 
> still required as long as one wants to receive VANISHED instead of 
> EXPUNGE.

Exactly.

> My apologies for assuming that it's useless :).
>
> Also is probably means that a QRESYNC-capable clients have to use 
> SELECT ... CONDSTORE when they open a mailbox for the first time.

This can be an option.

> I'd appreciate if someone could verify these assumptions -- they look 
> plausible to me, but I didn't see any flaw in my previous reasoning, 
> either :).
Reply
E-mail headers
From: jkt@flaska.net
To: imap-protocol@localhost
Date: Fri, 08 Jun 2018 12:34:48 -0000
Message-ID: 4FD75715.2040607@flaska.net permalink / raw / eml / mbox
Hi Alexey,

On 06/11/12 21:08, Alexey Melnikov wrote:
>> Shall I remove any messages upon receiving the VANISHED response?
>> Shall I send a UID SEARCH command to find out what new messages are
>> really there? That'd complicate my code quite a lot,
>> unfortunately.
> 
> In most cases you don't need to do anything. For example if you only
> cached a part of the mailbox (e.g. N most recent messages), and UIDs
> listed in VANISHED are below any UID you know about, then you don't
> really care about removed messages.
> 
> It might make a difference if you want to display the number of
> messages in the mailbox or use message numbers for some operations.
> If you cached the whole mailbox, then you know the whole msgno-to-UID
> map. If you only cached a part, then maybe doing something like "UID
> FETCH *" (or a similar SEARCH) would help.

I always establish full seq -> UID mapping as the very first thing when
I open a mailbox. The API through which I make the data about a mailbox
accessible to the rest of the application really wants to know how many
messages are there in a mailbox at any time; showing a total number of
messages in a mailbox is one of the use cases, but not the only one.
That's why I react to an EXISTS either by:

- doing nothing if the number is the same as my current idea of the
number of messages,
- throwing an error if the server tried to decrease the number of
messages against what I believe shall be there,
- asking for UIDs of the new arrivals immediately through UID FETCH
(FLAGS) immediately.

As soon as my idea of the "total number of messages" begins to differ
from the server's idea, I have trouble. That's an assumption on which
I've built my client; it allows me to deal with EXPUNGEs properly, etc.
My client will essentially show just a "loading..." placeholder until
the UID for a message arrives.

However, now QRESYNC seems to threaten this model because the server
reports increases in the amount of messages through EXISTS and their
removals through VANISHED. The issue is that there's a window where
VANISHED can refer to messages whose UID is unknown to the client and
that the protocol explicitly allows VANISHED to refer to UIDs which have
never existed in the mailbox -- at least according to my understanding.
I'd love to be proved wrong.

Unless I'm mistaken, the only completely safe way out of that is to
issue UID SEARCH ALL (or the ESEARCH equivalent) when a VANISHED
referencing "unknown" UIDs arrives at the time the mailbox has messages
whose UID I don't know yet.

Would you think that this will fly?

Would a proposal for adding "* ARRIVED 64,65,66" to replace EXISTS have
any real-world chance of getting accepted?

>> Even more entertaining would be an interaction where the server 
>> occasionally sent a regular EXPUNGED instead of VANISHED (it's
>> allowed to do so per RFC 5162); that'd lead to an interesting mix
>> of unknowns about a mailbox' state...
> 
> I hope no server does that (unless in different sessions, when
> QRESYNC is enabled in one and not another...).

Agreed. It's just that now I've implemented the RFC in my client, I'm
afraid there are ways of getting it out-of-sync through "legal"
responses; I'd like to mitigate that.

With kind regards,
Jan

-- 
Trojita, a fast e-mail client -- http://trojita.flaska.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 270 bytes
Desc: OpenPGP digital signature
URL: <http://mailman13.u.washington.edu/pipermail/imap-protocol/attachments/20120612/7a5fc86d/attachment.sig>
Reply
E-mail headers
From: alexey.melnikov@isode.com
To: imap-protocol@localhost
Date: Fri, 08 Jun 2018 12:34:48 -0000
Message-ID: 4FD77DE4.2080602@isode.com permalink / raw / eml / mbox
On 12/06/2012 15:49, Jan Kundr?t wrote:
> Hi Alexey,

Hi Jan,

> On 06/11/12 21:08, Alexey Melnikov wrote:
>>> Shall I remove any messages upon receiving the VANISHED response?
>>> Shall I send a UID SEARCH command to find out what new messages are
>>> really there? That'd complicate my code quite a lot,
>>> unfortunately.
>> In most cases you don't need to do anything. For example if you only
>> cached a part of the mailbox (e.g. N most recent messages), and UIDs
>> listed in VANISHED are below any UID you know about, then you don't
>> really care about removed messages.
>>
>> It might make a difference if you want to display the number of
>> messages in the mailbox or use message numbers for some operations.
>> If you cached the whole mailbox, then you know the whole msgno-to-UID
>> map. If you only cached a part, then maybe doing something like "UID
>> FETCH *" (or a similar SEARCH) would help.
> I always establish full seq ->  UID mapping as the very first thing when
> I open a mailbox. The API through which I make the data about a mailbox
> accessible to the rest of the application really wants to know how many
> messages are there in a mailbox at any time; showing a total number of
> messages in a mailbox is one of the use cases, but not the only one.
> That's why I react to an EXISTS either by:
>
> - doing nothing if the number is the same as my current idea of the
> number of messages,
> - throwing an error if the server tried to decrease the number of
> messages against what I believe shall be there,
> - asking for UIDs of the new arrivals immediately through UID FETCH
> (FLAGS) immediately.
>
> As soon as my idea of the "total number of messages" begins to differ
> from the server's idea, I have trouble. That's an assumption on which
> I've built my client; it allows me to deal with EXPUNGEs properly, etc.
> My client will essentially show just a "loading..." placeholder until
> the UID for a message arrives.
>
> However, now QRESYNC seems to threaten this model because the server
> reports increases in the amount of messages through EXISTS and their
> removals through VANISHED. The issue is that there's a window where
> VANISHED can refer to messages whose UID is unknown to the client and
> that the protocol explicitly allows VANISHED to refer to UIDs which have
> never existed in the mailbox -- at least according to my understanding.
> I'd love to be proved wrong.

My server doesn't reference UIDs which never existed, but I would not be 
surprised if other do. So you can't make this assumption.

> Unless I'm mistaken, the only completely safe way out of that is to
> issue UID SEARCH ALL (or the ESEARCH equivalent) when a VANISHED
> referencing "unknown" UIDs arrives at the time the mailbox has messages
> whose UID I don't know yet.
I thought ignoring data for UIDs you don't know was an Ok idea. But if you really can't do that, that should work. Although I would change that to "UID SEARCH<last-known-UID>:*" instead. As this will generate less traffic (and the server needs to do less work).


> Would you think that this will fly?
>
> Would a proposal for adding "* ARRIVED 64,65,66" to replace EXISTS have
> any real-world chance of getting accepted?
Even if it would be, we can't just add "ARRIVED" to QRESYNC, because it 
is an RFC and I believer there are multiple server implementations 
already. We can reopen the document and define a new IMAP capability, 
but in short to medium term your code would have to handle the current 
situation anyway...

>>> Even more entertaining would be an interaction where the server
>>> occasionally sent a regular EXPUNGED instead of VANISHED (it's
>>> allowed to do so per RFC 5162); that'd lead to an interesting mix
>>> of unknowns about a mailbox' state...
>> I hope no server does that (unless in different sessions, when
>> QRESYNC is enabled in one and not another...).
> Agreed. It's just that now I've implemented the RFC in my client, I'm
> afraid there are ways of getting it out-of-sync through "legal"
> responses; I'd like to mitigate that.
Reply
E-mail headers
From: jkt@flaska.net
To: imap-protocol@localhost
Date: Fri, 08 Jun 2018 12:34:48 -0000
Message-ID: 50006794.6050401@flaska.net permalink / raw / eml / mbox
On 06/12/12 19:35, Alexey Melnikov wrote:
>> Would a proposal for adding "* ARRIVED 64,65,66" to replace EXISTS have
>> any real-world chance of getting accepted?
> Even if it would be, we can't just add "ARRIVED" to QRESYNC, because it
> is an RFC and I believer there are multiple server implementations
> already. We can reopen the document and define a new IMAP capability,
> but in short to medium term your code would have to handle the current
> situation anyway...

I've tried to define an extension adding the ARRIVED response to 
QRESYNC.  The full text in HTML format is available at [1], source in 
rfc2xml format at [2].

I'm not familiar with the IETF process and such, and I'll also 
appreciate some feedback before I submit it further -- so I'm open to 
suggestions about what to do here. If you (anyone on the list) feel like 
this is a waste of time, a great idea or anything in between, please let 
me know.

I've also taken the liberty of not requiring an explicit ENABLE 
QRESYNC-ARRIVED; it seems to me that the mere act of SELECT ... 
QRESYNC-ARRIVED is explicit enough and the extra ENABLE is in fact not 
necessary.

I'll add code supporting this extension to my client shortly (probably 
as "X-DRAFT-I00-QRESYNC-ARRIVED", that's the correct format, right?); if 
any server vendors feel like implementing it as well for 
interoperability testing, I'll offer a beer to the first such person I 
meet in real life again :).

With kind regards
Jan

[1] http://trojita.flaska.net/draft-imap-qresync-arrived-00.html
[2] 
https://gitorious.org/trojita/trojita/blobs/drafts/draft-imap-qresync-arrived-00/docs/proposed-extensions/draft-imap-qresync-arrived.xml

-- 
Trojita, a fast e-mail client -- http://trojita.flaska.net/
Reply
E-mail headers
From: jkt@flaska.net
To: imap-protocol@localhost
Date: Fri, 08 Jun 2018 12:34:48 -0000
Message-ID: 5000AEC8.1020205@flaska.net permalink / raw / eml / mbox
I've fixed a few ambiguities in my proposed ARRIVED response draft. 
Updated version is at [1], source at [2]. These changes are:

- Clarified that UIDs presented in the ARRIVED response MUST be always 
presented in a sorted order
- Used a special non-terminal in the ABNF grammar
- Used correct format for FETCH responses
- Clarify that EXISTS must be sent at least once and SHOULD be sent only 
once
- Clarify that ARRIVED MUST NOT occur before the tagged response to 
SELECT/EXAMINE
- Clarify that arrivals since the last time are to be reported through 
usual UID FETCH, as in old QRESYNC

This -01 version is also what I've implemented in Trojita under 
capability of X-DRAFT-I01-QRESYNC-ARRIVED. A simple conversation is 
depicted in a unit test [3].

Please accept my apologies if this is too high frequency of updates -- 
just let me know and I'll introduce longer delays to the process; I 
*have* read the original version after finishing it, yet missed a few 
issues -- I should have definitely finished my implementation before 
posting. Sorry for that.

[1] http://trojita.flaska.net/draft-imap-qresync-arrived-01.html
[2] 
https://gitorious.org/trojita/trojita/blobs/drafts/draft-imap-qresync-arrived-01/docs/proposed-extensions/draft-imap-qresync-arrived.xml
[3] 
https://gitorious.org/trojita/trojita/blobs/drafts/draft-imap-qresync-arrived-01/tests/tests/test_Imap_Tasks_ObtainSynchronizedMailbox/test_Imap_Tasks_ObtainSynchronizedMailbox.cpp#line1948

With kind regards,
Jan

-- 
Trojita, a fast e-mail client -- http://trojita.flaska.net/
Reply