Re: [Imap-protocol] COPYUID message order

Alexey Melnikov <[email protected]> Sat, 23 May 2015 11:53:36 +0100
Newsgroups gmane.mail.imap.general
Message-ID <[email protected]>
--===============1064591635781418914==
Content-Type: multipart/alternative;
	boundary=Apple-Mail-AACFA665-3CEC-4079-A48D-70C59648A04C
Content-Transfer-Encoding: 7bit


--Apple-Mail-AACFA665-3CEC-4079-A48D-70C59648A04C
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: quoted-printable

Hi Bill,

> On 23 May 2015, at 02:00, Bill Shannon <[email protected]> wrote:
>=20
> I so wish there were compatibility tests for servers, rather than "it didn=
't break any clients so it must be good enough".  :-)
>=20
> Ok, how about this.  If I sort the original message numbers, and sort the r=
eturned source and destination UIDs, the result will be one-to-one, right?  T=
he first message number will correspond to the first source UID, which will c=
orrespond to the first destination UID, right?  And all three sets will have=
 exactly the same cardinality?

Yes. I don't think it really matters in which order messages are copied, as l=
ong as the matching UIDs are returned correctly.

>=20
> Brandon Long wrote on 05/22/2015 05:17 PM:
>> At least for Gmail, we always re-order the given set into sequence order (=
which is the same as uid order) before doing any operation.  So, the source U=
IDs in COPYUID are in the order in which they were copied.
>>=20
>> Since a COPY in Gmail is the equivalent of adding a label to a message, t=
he message may already have that label, so it may already be in the recipien=
t mailbox.  We always return the destination UIDs in the order which matches=
 the source UID order, so in your example, source UID 1 is destination UID 2=
, and source UID 2 is destination UID 1.
>>=20
>> When APPEND'ing a duplicate message, we update the UID assigned to the or=
iginal to be the newest UID in the mailbox (and that's returned with APPENDU=
ID), since we found clients typically assumed that was the case and could ge=
t confused.
>>=20
>> We could have done this with COPY, I guess, but we didn't see any client i=
ssues in testing, so we left it this way since the performance is better.
>>=20
>> Brandon
>>=20
>>> On Fri, May 22, 2015 at 4:46 PM, Bill Shannon <[email protected]> w=
rote:
>>> I'm unclear on the requirements around the COPY command and the COPYUID
>>> response code.
>>>=20
>>> Is there any guarantee that the order of messages in the COPY command is=

>>> the order they'll appear in the destination mailbox?  Or are they
>>> allowed to appear in any arbitrary order in the destination mailbox?
>>> (After any existing messages, of course.)
>>>=20
>>> RFC 4315 says of the COPYUID response:
>>>=20
>>>       The source UID set is in the order the message(s) were copied; the=

>>>       destination UID set corresponds to the source UID set and is in
>>>       the same order.
>>>=20
>>> Exactly what order is that?  Is it the order in which the messages were
>>> mentioned in the COPY command?  Is it the order they actually appear in
>>> the destination mailbox (assuming it can be different)?  Or is it in
>>> some other undefined order?
>>>=20
>>> With Gmail I'm getting
>>>=20
>>> A1 COPY 1:2 dest
>>> A1 OK [COPYUID 123456 1:2 2,1]
>>>=20
>>> and
>>>=20
>>> A1 COPY 2,1 dest
>>> A1 OK [COPYUID 123456 1:2 2,1]
>>>=20
>>> The order of the source UIDs is unrelated to the order the messages
>>> are mentioned in the COPY command and unrelated to the order they
>>> appear in the destination mailbox.
>>>=20
>>> If I don't know the UIDs of the source messages, is there any way to
>>> determine which message was copied to which UID in the destination
>>> mailbox?
>>> _______________________________________________
>>> Imap-protocol mailing list
>>> [email protected]
>>> http://mailman13.u.washington.edu/mailman/listinfo/imap-protocol
>=20
> _______________________________________________
> Imap-protocol mailing list
> [email protected]
> http://mailman13.u.washington.edu/mailman/listinfo/imap-protocol

--Apple-Mail-AACFA665-3CEC-4079-A48D-70C59648A04C
Content-Type: text/html;
	charset=utf-8
Content-Transfer-Encoding: 7bit

<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Bill,</div><div><br></div><div>On 23 May 2015, at 02:00, Bill Shannon &lt;<a href="mailto:[email protected]">[email protected]</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>
  
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  
  
    <div class="moz-cite-prefix">I <b>so</b> wish there were
      compatibility tests for servers, rather than "it didn't break any
      clients so it must be good enough".&nbsp; :-)<br>
      <br>
      Ok, how about this.&nbsp; If I sort the original message numbers, and
      sort the returned source and destination UIDs, the result will be
      one-to-one, right?&nbsp; The first message number will correspond to
      the first source UID, which will correspond to the first
      destination UID, right?&nbsp; And all three sets will have exactly the
      same cardinality?<br></div></div></blockquote><div><br></div>Yes. I don't think it really matters in which order messages are copied, as long as the matching UIDs are returned correctly.<div><br><blockquote type="cite"><div><div class="moz-cite-prefix">
      <br>
      Brandon Long wrote on 05/22/2015 05:17 PM:<br>
    </div>
    <blockquote cite="mid:CABa8R6tpd-2GPoSTX0_d8wnROvQpm4_zmMxconJDPPud3NNdww@mail.gmail.com" type="cite">
      <div dir="ltr">At least for Gmail, we always re-order the given
        set into sequence order (which is the same as uid order) before
        doing any operation.&nbsp; So, the source UIDs in COPYUID are in the
        order in which they were copied.
        <div><br>
          <div>Since a COPY in Gmail is the equivalent of adding a label
            to a message, the message may already have that label, so it
            may already be in the recipient mailbox.&nbsp; We always return
            the destination UIDs in the order which matches the source
            UID order, so in your example, source UID 1 is destination
            UID 2, and source UID 2 is destination UID 1.</div>
          <div><br>
          </div>
          <div>When APPEND'ing a duplicate message, we update the UID
            assigned to the original to be the newest UID in the mailbox
            (and that's returned with APPENDUID), since we found clients
            typically assumed that was the case and could get confused.</div>
          <div><br>
          </div>
          <div>We could have done this with COPY, I guess, but we didn't
            see any client issues in testing, so we left it this way
            since the performance is better.</div>
          <div><br>
          </div>
          <div>Brandon</div>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, May 22, 2015 at 4:46 PM, Bill
          Shannon <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm
            unclear on the requirements around the COPY command and the
            COPYUID<br>
            response code.<br>
            <br>
            Is there any guarantee that the order of messages in the
            COPY command is<br>
            the order they'll appear in the destination mailbox?&nbsp; Or are
            they<br>
            allowed to appear in any arbitrary order in the destination
            mailbox?<br>
            (After any existing messages, of course.)<br>
            <br>
            RFC 4315 says of the COPYUID response:<br>
            <br>
            &nbsp; &nbsp; &nbsp; The source UID set is in the order the message(s) were
            copied; the<br>
            &nbsp; &nbsp; &nbsp; destination UID set corresponds to the source UID set
            and is in<br>
            &nbsp; &nbsp; &nbsp; the same order.<br>
            <br>
            Exactly what order is that?&nbsp; Is it the order in which the
            messages were<br>
            mentioned in the COPY command?&nbsp; Is it the order they
            actually appear in<br>
            the destination mailbox (assuming it can be different)?&nbsp; Or
            is it in<br>
            some other undefined order?<br>
            <br>
            With Gmail I'm getting<br>
            <br>
            A1 COPY 1:2 dest<br>
            A1 OK [COPYUID 123456 1:2 2,1]<br>
            <br>
            and<br>
            <br>
            A1 COPY 2,1 dest<br>
            A1 OK [COPYUID 123456 1:2 2,1]<br>
            <br>
            The order of the source UIDs is unrelated to the order the
            messages<br>
            are mentioned in the COPY command and unrelated to the order
            they<br>
            appear in the destination mailbox.<br>
            <br>
            If I don't know the UIDs of the source messages, is there
            any way to<br>
            determine which message was copied to which UID in the
            destination<br>
            mailbox?<br>
            _______________________________________________<br>
            Imap-protocol mailing list<br>
            <a moz-do-not-send="true" href="mailto:[email protected]">[email protected]</a><br>
            <a moz-do-not-send="true" href="http://mailman13.u.washington.edu/mailman/listinfo/imap-protocol" target="_blank">http://mailman13.u.washington.edu/mailman/listinfo/imap-protocol</a><br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Imap-protocol mailing list</span><br><span><a href="mailto:[email protected]">[email protected]</a></span><br><span><a href="http://mailman13.u.washington.edu/mailman/listinfo/imap-protocol">http://mailman13.u.washington.edu/mailman/listinfo/imap-protocol</a></span></div></blockquote></div></body></html>
--Apple-Mail-AACFA665-3CEC-4079-A48D-70C59648A04C--

--===============1064591635781418914==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Imap-protocol mailing list
[email protected]
http://mailman13.u.washington.edu/mailman/listinfo/imap-protocol
--===============1064591635781418914==--