Bug 3601 - Mail lost when moving folder in IMAP
Summary: Mail lost when moving folder in IMAP
Status: NEW
Alias: None
Product: Claws Mail
Classification: Unclassified
Component: Folders/IMAP (show other bugs)
Version: 3.14.0
Hardware: PC Linux
: P3 major
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2016-01-23 14:10 CET by Keith Edmunds
Modified: 2016-10-06 18:25 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Edmunds 2016-01-23 14:10:27 CET
IMAP server: Dovecot 2.2.13

When moving a folder containing mail to another location within the folder tree, the destination folder is created but the contents of the source folder are not copied; the source folder and contents are deleted. The result is an empty destination folder.

It may be that Dovecot is, in some way, contributing to this. I've posted the IMAP log below (I've changed the name of the IMAP server in the logs, but otherwise unedited). A few observations:

- Dovecot reports that the destination folder is created, yet reports it doesn't exist when Claws tries to SUBSCRIBE to it. This may be some kind of race condition; when the entire operation is complete, the destination folder *does* exist.

- There is an error when Claws SUBSCRIBEs to the destination folder, but Claws doesn't check for errors at that point.

- After Claws issues the COPY, Dovecot reports NO. I believe, at this point, Claws should abort the move. Even if the original bug is within Dovecot (and that's not clear), once Claws is told that the COPY has failed, it should not go on to delete the source mails and folder.

I can reliably reproduce this. The situation may be made more complex by the fact that the destination folder is a "public" folder within Dovecot; however, the key issue above is that Claws continues with the deletion of the source mails and folder despite being told that the copy has failed.

A first pass of the code suggests that this may be an Etpan bug, possibly within threaded_run().

I'm happy to do more research or test potential fixes.

IMAP log, moving folder 'test' to 'public/accounts':

* Account 'TCL': Connecting to IMAP4 server: imap.example.com:993...
[12:37:08] IMAP4< * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN] Dovecot ready. 
* IMAP connection is un-authenticated
[12:37:08] IMAP4> 1 CAPABILITY 
[12:37:08] IMAP4< * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN 
[12:37:08] IMAP4< 1 OK Pre-login capabilities listed, post-login capabilities have more. 
[12:37:08] IMAP4> Logging kae to imap.example.com using LOGIN
[12:37:08] IMAP4< Logged in
[12:37:08] IMAP4< Login to imap.example.com successful
[12:37:08] IMAP4> 3 LIST "" "" 
[12:37:08] IMAP4< * LIST (\Noselect) "/" "" 
[12:37:08] IMAP4< 3 OK List completed. 
[12:37:08] IMAP4> 4 LIST "" "public/accounts/test" 
[12:37:08] IMAP4< 4 OK List completed. 
[12:37:08] IMAP4> 5 CREATE "public/accounts/test" 
[12:37:08] IMAP4< 5 OK Create completed. 
[12:37:08] IMAP4> 6 LIST "" "public/accounts/test" 
[12:37:08] IMAP4< 6 OK List completed. 
[12:37:08] IMAP4> 7 SUBSCRIBE "public/accounts/test" 
[12:37:08] IMAP4< 7 NO Mailbox doesn't exist: public/accounts/test 
* Moving test to public/accounts/test...
[12:37:08] IMAP4> 8 SELECT test 
[12:37:08] IMAP4< * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 
[12:37:08] IMAP4< * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted. 
[12:37:08] IMAP4< * 2 EXISTS 
[12:37:08] IMAP4< * 0 RECENT 
[12:37:08] IMAP4< * OK [UIDVALIDITY 1251379324] UIDs valid 
[12:37:08] IMAP4< * OK [UIDNEXT 3] Predicted next UID 
[12:37:08] IMAP4< 8 OK [READ-WRITE] Select completed (0.000 secs). 
[12:37:08] IMAP4> 9 UID COPY 1:2 "public/accounts/test" 
[12:37:08] IMAP4< 9 NO [TRYCREATE] Mailbox doesn't exist: public/accounts/test 
** IMAP error on imap.example.com: UID COPY error
[12:37:08] IMAP4> 10 UID STORE 1:2 +FLAGS.SILENT (\Deleted) 
[12:37:08] IMAP4< 10 OK Store completed. 
[12:37:08] IMAP4> 11 EXPUNGE 
[12:37:08] IMAP4< * 2 EXPUNGE 
[12:37:08] IMAP4< * 1 EXPUNGE 
[12:37:08] IMAP4< 11 OK Expunge completed. 
[12:37:08] IMAP4> 12 UNSUBSCRIBE test 
[12:37:08] IMAP4< 12 OK Unsubscribe completed.                                                                                                                        
[12:37:08] IMAP4> 13 CLOSE                                                                                                                                            
[12:37:08] IMAP4< 13 OK Close completed.                                                                                                                              
[12:37:08] IMAP4> 14 DELETE test                                                                                                                                      
[12:37:09] IMAP4< 14 OK Delete completed.                                                                                                                             
[12:37:09] IMAP4> 15 STATUS "public/accounts/test" (MESSAGES UIDNEXT UIDVALIDITY UNSEEN)                                                                              
[12:37:09] IMAP4< 15 NO Mailbox doesn't exist: public/accounts/test                                                                                                   
** IMAP error on imap.example.com: STATUS error
Comment 1 Michael Rasmussen 2016-01-23 14:48:40 CET
(In reply to comment #0)
> [12:37:08] IMAP4> 5 CREATE "public/accounts/test" 
> [12:37:08] IMAP4< 5 OK Create completed. 
> [12:37:08] IMAP4> 6 LIST "" "public/accounts/test" 
> [12:37:08] IMAP4< 6 OK List completed. 
> [12:37:08] IMAP4> 7 SUBSCRIBE "public/accounts/test" 
> [12:37:08] IMAP4< 7 NO Mailbox doesn't exist: public/accounts/test 
> * Moving test to public/accounts/test...
Looks like either a permission problem on the server or malfunctioning configuration of the server.
Comment 2 Keith Edmunds 2016-01-23 16:57:50 CET
Possibly. However, the fact remains that Claws deletes the source folder
after it has been told the copy has failed. That is a Claws bug.
Comment 3 Ricardo Mones 2016-04-13 10:28:23 CEST
I think just found today another instance of this one, but copying a single mail. This one didn't get lost though, just marked as "to be moved" (but I have immediate execute on, so execute button and menu option are disabled…).

I find strange that after having received a NO and a BYE some stray thread is still trying to send a NOOP, which of course fails :-)

[10:08:28] IMAP4> 168 NOOP 
[10:08:28] IMAP4< 168 OK NOOP completed. 
[10:09:20] IMAP4> 169 UID COPY 5212 Team 
[10:09:20] IMAP4< 169 NO Server Unavailable. 15 
[10:09:20] IMAP4< * BYE Connection closed. 
** IMAP error on outlook.office365.com: UID COPY error
[10:09:28] IMAP4> 170 NOOP 
** IMAP error on outlook.office365.com: stream error
** IMAP4 connection broken