From 3f1aca1a80e41bb6e8d7ff30bc45f920f3a82590 Mon Sep 17 00:00:00 2001
From: Guilhem Moulin <guilhem@fripost.org>
Date: Sun, 6 Sep 2015 20:51:37 +0200
Subject: Message Sequence Match Data: sequence set come before UIDs.

Cf. RFC 7162:

  seq-match-data = "(" known-sequence-set SP known-uid-set ")"
---
 imapsync             |  8 ++++----
 lib/Net/IMAP/Sync.pm | 14 +++++++-------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/imapsync b/imapsync
index ac63577..927d205 100755
--- a/imapsync
+++ b/imapsync
@@ -619,10 +619,10 @@ sub delete_mapping($$) {
 }
 
 
-# Create a sample (UIDs, sequence numbers) to use as 3rd and 4th
-# argument of the QRESYNC parameters to the SELECT command.
+# Create a sample (sequence numbers, UIDs) to use as Message Sequence
+# Match Data for the QRESYNC parameter to the SELECT command.
 # QRESYNC [RFC7162] doesn't force the server to remember the MODSEQs of
-# EXPUNGEd messages.  By passing a sample of known UIDs/sequence numbers
+# EXPUNGEd messages.  By passing a sample of known sequence numbers/UIDs
 # we let the server know that the messages have been EXPUNGEd [RFC7162,
 # section 3.2.5.2].
 # The UID set is the largest set of higest UIDs with at most 1024 UIDs,
@@ -660,7 +660,7 @@ sub sample($$$) {
         $uids = ($min == $max ? $min : "$min:$max")
                .(defined $uids ? ','.$uids : '');
     }
-    return ( $uids, ($count - $n + 1).':'.$count );
+    return ( ($count - $n + 1).':'.$count, $uids );
 }
 
 
diff --git a/lib/Net/IMAP/Sync.pm b/lib/Net/IMAP/Sync.pm
index ca85a54..785aa54 100644
--- a/lib/Net/IMAP/Sync.pm
+++ b/lib/Net/IMAP/Sync.pm
@@ -482,12 +482,12 @@ sub search($$) {
 }
 
 
-# $self->select($mailbox,  [$UIDs, $seqs])
-# $self->examine($mailbox, [$UIDs, $seqs])
+# $self->select($mailbox,  [$seqs, $UIDs])
+# $self->examine($mailbox, [$seqs, $UIDs])
 #   Issue a SELECT or EXAMINE command for the $mailbox. Upon success,
 #   change the state to SELECTED, otherwise go back to AUTH.
-#   The optional $UIDs and $seqs are passed are 3rd and 4th arguments to
-#   the QRESYNC parameter, respectively.
+#   The optional $seqs and $UIDs are used as Message Sequence Match
+#   Data for the QRESYNC parameter to the SELECT command.
 sub select($$;$$) {
     my $self = shift;
     my $mailbox = shift;
@@ -1278,11 +1278,11 @@ sub _open_mailbox($$) {
 }
 
 
-# $self->_select_or_examine($command, $mailbox, [$UIDs, $seqs])
+# $self->_select_or_examine($command, $mailbox, [$seqs, $UIDs])
 #   Issue a SELECT or EXAMINE command for the $mailbox.  Upon success,
 #   change the state to SELECTED, otherwise go back to AUTH.
-#   The optional $UIDs and $seqs are passed are 3rd and 4th arguments to
-#   the QRESYNC parameter, respectively.
+#   The optional $seqs and $UIDs are used as Message Sequence Match
+#   Data for the QRESYNC parameter to the $command.
 sub _select_or_examine($$$;$$) {
     my $self = shift;
     my $command = shift;
-- 
cgit v1.2.3


From 6310edda1c366ff9510220d22d2dc8052e2c6066 Mon Sep 17 00:00:00 2001
From: Guilhem Moulin <guilhem@fripost.org>
Date: Sun, 6 Sep 2015 20:58:52 +0200
Subject: =?UTF-8?q?Fix=20typo:=20lUID=20=E2=86=94=20rUID.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 imapsync | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/imapsync b/imapsync
index 927d205..a454c5d 100755
--- a/imapsync
+++ b/imapsync
@@ -563,8 +563,8 @@ my $STH_GET_INTERRUPTED_BY_IDX = $DBH->prepare(q{
 my $STH_COUNT_MESSAGES = $DBH->prepare(q{SELECT COUNT(*) FROM mapping WHERE idx = ?});
 
 # List last 1024 messages UIDs
-my $STH_LASTUIDs_LOCAL  = $DBH->prepare(q{SELECT rUID FROM mapping WHERE idx = ? ORDER BY rUID DESC LIMIT 1024});
-my $STH_LASTUIDs_REMOTE = $DBH->prepare(q{SELECT lUID FROM mapping WHERE idx = ? ORDER BY lUID DESC LIMIT 1024});
+my $STH_LASTUIDs_LOCAL  = $DBH->prepare(q{SELECT lUID FROM mapping WHERE idx = ? ORDER BY lUID DESC LIMIT 1024});
+my $STH_LASTUIDs_REMOTE = $DBH->prepare(q{SELECT rUID FROM mapping WHERE idx = ? ORDER BY rUID DESC LIMIT 1024});
 
 
 # Download some missing UIDs from $source; returns the thew allocated UIDs
-- 
cgit v1.2.3


From c80864d8d544dd29c73c47c3911ac0e7993ed59b Mon Sep 17 00:00:00 2001
From: Guilhem Moulin <guilhem@fripost.org>
Date: Sun, 6 Sep 2015 21:26:00 +0200
Subject: Getopt::Long is a core module.

---
 INSTALL | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/INSTALL b/INSTALL
index 91cc19f..c9c1389 100644
--- a/INSTALL
+++ b/INSTALL
@@ -3,7 +3,7 @@ imapsync depends on the following Perl modules:
   - Config::Tiny
   - DBI
   - DBD::SQLite
-  - Getopt::Long
+  - Getopt::Long (core module)
   - MIME::Base64 (core module) if authentication is required
   - IO::Select (core module)
   - IO::Socket::INET (core module) for 'type=imap'
-- 
cgit v1.2.3