Hi,

I've come across a problem with mbsync. I tried to file a bug report, but
the "submit ticket" button in the bug tracker was greyed out for me, so I'm
reporting it here instead.

I use mbsync to sync between a remote Oracle Beehive IMAP server and a
local Dovecot IMAP server. If a new mail is created on the local server,
that mail is copied to the remote server every time mbsync runs, resulting
in multiple copies of the mail message. I'm also seeing this when the local
side is a maildir store instead of a Dovecot server, so I suspect the bug
is in the interaction with the remote server.

I've attached the output from running "mbsync -a --debug-net-all
--debug-main --debug-sync" on a minimized configuration, syncing a local
maildir against the remote IMAP server. (Some folder and host names
redacted.) The logged session copied one mail from the local maildir to the
remote server, even though multiple copies of the mail already exist on the
server.

I used mbsync compiled from the master branch of the git repository to
produce the debug log.

To me it looks like the problem is the response from the server when
fetching the X-TUID header:

>>> 9 UID FETCH 8:1000000000 (UID BODY.PEEK[HEADER.FIELDS (X-TUID)])
* 8 FETCH (UID 8 BODY[HEADER.FIELDS ("X-TUID")] {24}
=========
X-tuid: gVqG+EOmudjX
=========
)
9 OK UID FETCH completed
matching just copied messages on master
  pair(-2,1): lookup master, TUID gVqG+EOmudjX
  -> TUID lost
Warning: lost track of 1 pushed message(s)

mbsync seems to expect the header name to be in all capital letters,
whereas only the first letter of the header name is in uppercase in the
response from the server.

My guess is that parse_fetch_rsp() will have to be changed to do a
case-insensitive check of the response header. That is, the following line
in drv_imap.c needs to do a case-insensitive comparison:

                    if (starts_with( tmp->val, tmp->len, "X-TUID: ", 8 ))

Just as a quick test, I replaced "X-TUID: " with "X-tuid: " on that line
and recompiled, and then the syncing started behaving as expected. But that
will of course break it for everyone else.


Best regards,

-- 
Knut Anders
Reading configuration file /home/testuser/.mbsyncrc
Channel imap
Opening master store imap-remote...
Resolving **HOSTNAME**... ok
Connecting to **HOSTNAME** (**IP**:993)... 
Opening slave store maildir...
pattern 'testbox' (effective 'testbox'): Path, no INBOX
got mailbox list from slave:
  testbox
Connection is now encrypted
* OK server ready. Unauthorized Access Prohibited.
>>> 1 CAPABILITY
* CAPABILITY IMAP4REV1 IDLE AUTH=PLAIN
1 OK CAPABILITY completed
Logging in...
>>> 2 LOGIN <user> <pass>
2 OK LOGIN completed
pattern 'testbox' (effective 'testbox'): Path, no INBOX
>>> 3 LIST "" "*"
* LIST () "/" "Documents"
* LIST () "/" "Drafts"
* LIST () "/" "INBOX"
....
* LIST () "/" "testbox"
* LIST () "/" "Trash"
3 OK LIST completed
got mailbox list from master:
  Trash
  testbox
....
  INBOX
  Drafts
  Documents
reading sync state /home/testuser/.mbsync/:imap-remote:testbox_:maildir:testbox 
...
  entry (-2,1,0,)
  entry (1,2,8,)
  entry (2,3,8,)
  entry (3,4,8,)
  entry (4,5,8,)
  entry (5,6,8,)
  entry (6,7,8,)
Opening master box testbox...
>>> 4 SELECT "testbox"
Opening slave box testbox...
* 7 EXISTS
* 1 RECENT
* OK [UIDVALIDITY 21802084] UID validity status
* OK [UIDNEXT 8] Predicted next UID
* FLAGS (\Seen \Deleted \Answered \Forwarded \Redirected \Flagged \Hidden 
\Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Deleted \Answered \Forwarded \Redirected \Flagged 
\Hidden \Draft $MDNSent)] Permanent flags
4 OK [READ-WRITE] SELECT completed
Loading master...
loading master [1,inf]
>>> 5 UID FETCH 1:7 (UID FLAGS)
Loading slave...
loading slave [1,inf]
slave: 7 messages, 0 recent
matching messages on slave against sync records
  message     1, S   : pairs    -2
  message     2, S   : pairs     1
  message     3, S   : pairs     2
  message     4, S   : pairs     3
  message     5, S   : pairs     4
  message     6, S   : pairs     5
  message     7, S   : pairs     6
* 1 FETCH (UID 1 FLAGS (\Seen))
* 2 FETCH (UID 2 FLAGS (\Seen))
* 3 FETCH (UID 3 FLAGS (\Seen))
* 4 FETCH (UID 4 FLAGS (\Seen))
* 5 FETCH (UID 5 FLAGS (\Seen))
* 6 FETCH (UID 6 FLAGS (\Seen))
* 7 FETCH (UID 7 FLAGS (\Seen \Recent))
5 OK UID FETCH completed
master: 7 messages, 1 recent
matching messages on master against sync records
  message     1, S   : pairs     2
  message     2, S   : pairs     3
  message     3, S   : pairs     4
  message     4, S   : pairs     5
  message     5, S   : pairs     6
  message     6, S   : pairs     7
  message     7, S   : new
Synchronizing...
synchronizing old entries
pair (-2,1)
pair (1,2)
  pushing flags: + -
  pulling flags: + -
pair (2,3)
  pushing flags: + -
  pulling flags: + -
pair (3,4)
  pushing flags: + -
  pulling flags: + -
pair (4,5)
  pushing flags: + -
  pulling flags: + -
pair (5,6)
  pushing flags: + -
  pulling flags: + -
pair (6,7)
  pushing flags: + -
  pulling flags: + -
synchronizing new entries
new message 1 on slave
  -> pair(-2,1) exists
  -> updated flags to 8
  -> pushing message, TUID gVqG+EOmudjX
new message 7 on master
  -> pair(7,-2) created
  -> updated flags to 8
  -> pulling message, TUID ppIvYmPO9NJG
synchronizing flags
propagating new messages
>>> 6 APPEND "testbox" (\Seen) {137}
+ Ready for additional command text
(1 in progress) >>> 7 UID FETCH 7 (BODY.PEEK[])
* 8 EXISTS
* 2 RECENT
6 OK APPEND completed
finding just copied messages on master
(1 in progress) >>> 8 CHECK
* 7 FETCH (BODY[] {137}
=========
To: 
Subject: 
From: testuser@ugle
Gcc: nnfolder+archive:sent.2015-11
Date: Fri, 06 Nov 2015 21:36:15 +0100
X-TUID: vX8xAac9MUXy

=========
 UID 7)
7 OK UID FETCH completed
  -> new UID 8 on slave
8 OK CHECK completed
>>> 9 UID FETCH 8:1000000000 (UID BODY.PEEK[HEADER.FIELDS (X-TUID)])
* 8 FETCH (UID 8 BODY[HEADER.FIELDS ("X-TUID")] {24}
=========
X-tuid: gVqG+EOmudjX

=========
)
9 OK UID FETCH completed
matching just copied messages on master
  pair(-2,1): lookup master, TUID gVqG+EOmudjX
  -> TUID lost
Warning: lost track of 1 pushed message(s)
>>> 10 LOGOUT
* BYE Oracle Beehive IMAP server terminating connection
10 OK LOGOUT completed
------------------------------------------------------------------------------
_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to