Bug 324932 - Cannot delete IMAP folder
Summary: Cannot delete IMAP folder
Status: RESOLVED FIXED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: IMAP resource (show other bugs)
Version: 4.11
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Kevin Ottens
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-15 14:50 UTC by Thomas Tanghus
Modified: 2014-06-06 08:25 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.11.3
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Tanghus 2013-09-15 14:50:52 UTC
I have a folder INBOX.Notifications.BoxeeHacks which I try to delete.
In akonadiconsole debug information view I get:

NotificationManager::notify ( Items () in collection 1007 removed )
NotificationManager::notify ( Collections ((1007,.BoxeeHacks)) in collection 66 removed )
AgentBase(akonadi_imap_resource_1): Failed to delete the folder, restoring folder list.
NotificationManager::notify ( Collections ((1050,.BoxeeHacks)) in collection 66 added )

And in the all tab:

kontact-936017334 (0x22767f0) 4019 DELETE 1054 
kontact-936017334 (0x22767f0) 4019 OK DELETE completed 
akonadi_imap_resource_1 (0x222ed70) 29225 LSUB 66 0 () (STATISTICS true ANCESTORS INF) 
akonadi_imap_resource_1 (0x222ed70) * 66 63 (NAME "Notifications" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".Notifications" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ANCESTORS ((63 ".INBOX") (62 "imap://xxx@xxx.com/") (0 "")) collectionquota "440368128 1048576000" imapacl "administrators lrswicda % owner lrswicda %% " imapquota "ROOT %%%% STORAGE % 1024000 %%%% STORAGE % 430047" uidnext "-1" collectionflags "\\* \\Draft \\Answered \\Flagged \\Deleted \\Seen" uidvalidity "1315935953" AccessRights "a" timestamp "1378490810") 
akonadi_imap_resource_1 (0x222ed70) 29225 OK List completed 
akonadi_imap_resource_1 (0x222ed70) 29226 LSUB 506 0 (RESOURCE akonadi_imap_resource_1) (STATISTICS true ANCESTORS INF) 
akonadi_imap_resource_1 (0x222ed70) * 506 66 (NAME "currency-converter" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".currency-converter" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 MESSAGES 66 UNSEEN 0 SIZE 1749515 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ANCESTORS ((66 ".Notifications") (63 ".INBOX") (62 "imap://xxx@xxx.com/") (0 "")) collectionquota "434748416 1048576000" imapquota "ROOT %%%% STORAGE % 1024000 %%%% STORAGE % 424559" uidnext "-1" collectionflags "$SIGNED $ATTACHMENT $SENT $REPLIED \\* \\Draft \\Answered \\Flagged \\Deleted \\Seen" uidvalidity "1341399276" imapacl "administrators lrswicda % owner lrswicda %% " timestamp "1378141625") 
akonadi_imap_resource_1 (0x222ed70) 29226 OK List completed 
akonadi_imap_resource_1 (0x222ed70) 29227 SELECT SILENT 506 
akonadi_imap_resource_1 (0x222ed70) 29227 OK Completed 
akonadi_imap_resource_1_body_checker (0x223c6a0) 11196 SELECT SILENT 506 
akonadi_imap_resource_1_body_checker (0x223c6a0) 11196 OK Completed 
akonadi_imap_resource_1 (0x222ed70) 29228 FETCH 1:* CACHEONLY EXTERNALPAYLOAD (UID REMOTEID REMOTEREVISION COLLECTIONID FLAGS SIZE) 
akonadi_imap_resource_1_body_checker (0x223c6a0) 11197 FETCH 1:* CACHEONLY CHECKCACHEDPARTSONLY EXTERNALPAYLOAD (UID REMOTEID REMOTEREVISION COLLECTIONID FLAGS SIZE 
---snip---
akonadi_imap_resource_1 (0x222ed70) 29292 CREATE "BoxeeHacks" 66 (MIMETYPE (message/rfc822 inode/directory) REMOTEID ".BoxeeHacks" REMOTEREVISION "" VIRTUAL 0 CACHEPOLICY (INHERIT true)) 
akonadi_imap_resource_1 (0x222ed70) * 1055 66 (NAME "BoxeeHacks" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".BoxeeHacks" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ) 
akonadi_imap_resource_1 (0x222ed70) 29292 OK CREATE completed 
akonadi_imap_resource_1 (0x222ed70) 29293 COMMIT 
akonadi_imap_resource_1 (0x222ed70) 29293 OK Commit completed 
akonadi_newmailnotifier_agent (0x2238270) 158 LSUB 1055 0 () (ANCESTORS INF) 
Archive Mail Kernel ETM (0x21d7a10) 1374 LSUB 1055 0 () (STATISTICS true ANCESTORS INF) 
kalarm-1223389481 (0x21ea0a0) 4074 LSUB 1055 0 () (ANCESTORS INF) 
kalarm-1223389481 (0x21ea0a0) * 1055 66 (NAME "BoxeeHacks" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".BoxeeHacks" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ANCESTORS ((66 ".Notifications") (63 ".INBOX") (62 "imap://xxx@xxx.com/") (0 "")) ) 
kalarm-1223389481 (0x21ea0a0) 4074 OK List completed 
akonadi_nepomuk_feeder (0x2232b00) 867 LSUB 1055 0 () () 
akonadi_nepomuk_feeder (0x2232b00) * 1055 66 (NAME "BoxeeHacks" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".BoxeeHacks" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ) 
akonadi_nepomuk_feeder (0x2232b00) 867 OK List completed 
MailFilter Kernel ETM (0x2246d50) 1374 LSUB 1055 0 () (STATISTICS true ANCESTORS INF) 
ETMCalendar (0x21fa1c0) 14836 LSUB 1055 0 () (ANCESTORS INF) 
ETMCalendar (0x21fa1c0) * 1055 66 (NAME "BoxeeHacks" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".BoxeeHacks" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ANCESTORS ((66 ".Notifications") (63 ".INBOX") (62 "imap://xxx@xxx.com/") (0 "")) ) 
ETMCalendar (0x21fa1c0) 14836 OK List completed 
akonadi_newmailnotifier_agent (0x2238270) * 1055 66 (NAME "BoxeeHacks" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".BoxeeHacks" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ANCESTORS ((66 ".Notifications") (63 ".INBOX") (62 "imap://xxx@xxx.com/") (0 "")) ) 
akonadi_newmailnotifier_agent (0x2238270) 158 OK List completed 
MailFilter Kernel ETM (0x2246d50) * 1055 66 (NAME "BoxeeHacks" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".BoxeeHacks" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ANCESTORS ((66 ".Notifications") (63 ".INBOX") (62 "imap://xxx@xxx.com/") (0 "")) ) 
MailFilter Kernel ETM (0x2246d50) 1374 OK List completed 
Archive Mail Kernel ETM (0x21d7a10) * 1055 66 (NAME "BoxeeHacks" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".BoxeeHacks" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ANCESTORS ((66 ".Notifications") (63 ".INBOX") (62 "imap://xxx@xxx.com/") (0 "")) ) 
Archive Mail Kernel ETM (0x21d7a10) 1374 OK List completed 
ETMCalendar (0x21ea4b0) 14850 LSUB 1055 0 () (ANCESTORS INF) 
KMail Kernel ETM (0x22cc8b0) 1902 LSUB 1055 0 () (STATISTICS true ANCESTORS INF) 
ETMCalendar (0x21ea4b0) * 1055 66 (NAME "BoxeeHacks" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".BoxeeHacks" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ANCESTORS ((66 ".Notifications") (63 ".INBOX") (62 "imap://xxx@xxx.com/") (0 "")) ) 
ETMCalendar (0x21ea4b0) 14850 OK List completed 
KMail Kernel ETM (0x22cc8b0) * 1055 66 (NAME "BoxeeHacks" MIMETYPE (message/rfc822 inode/directory) REMOTEID ".BoxeeHacks" REMOTEREVISION "" RESOURCE "akonadi_imap_resource_1" VIRTUAL 0 MESSAGES 0 UNSEEN 0 SIZE 0 CACHEPOLICY (INHERIT true INTERVAL 15 CACHETIMEOUT -1 SYNCONDEMAND true LOCALPARTS (ENVELOPE HEAD RFC822)) ANCESTORS ((66 ".Notifications") (63 ".INBOX") (62 "imap://xxx@xxx.com/") (0 "")) ) 
KMail Kernel ETM (0x22cc8b0) 1902 OK List completed 




Reproducible: Always

Steps to Reproduce:
1. RMB-click on an IMAP folder and select Delete
2. Watch the folder disappear only to reappear a moment later.

Actual Results:  
The folder reappears after deletion

Expected Results:  
The folder should be deleted remotely and locally.

This also happens with folder directly under INBOX

I believe my provider is using Courier IMAP
Kontact 4.11.1
Comment 1 Daniel Vrátil 2013-09-16 14:38:48 UTC
Could you please try following:

$ export KIMAP_LOGFILE=/home/.../kimap.log
$ akonadictl restart

This will log all the IMAP communication between the Akonadi resource and the IMAP server. Try to remove a folder from KMail and paste here content of the file (there might be multiple files, if you have multiple IMAP resoures, so you have to find the correct one :-)). Also make sure to strip any sensitive data - essentially the only part I'm interested in is the "DELETE" command and reply from the server, so you can remove rest of the communication completely (but please provide some lines before and below as well for better context).
Comment 2 Thomas Tanghus 2013-09-16 15:37:13 UTC
(In reply to comment #1)
> Could you please try following:
> 
> $ export KIMAP_LOGFILE=/home/.../kimap.log
> $ akonadictl restart

Just to be sure: Is the path  /home/.../kimap.log literately meant, or just to show that I should choose a path myself?
Comment 3 Daniel Vrátil 2013-09-16 16:01:39 UTC
You can choose yourself :) It does not have to even be called kimap.log
Comment 4 Thomas Tanghus 2013-09-17 18:46:40 UTC
(In reply to comment #3)
> You can choose yourself :) It does not have to even be called kimap.log

I thought so, but could be a fancy shell feature I didn't know ;)

Well the answer is pretty clear. Apparently you have to select a different folder before you can delete it. This has to be done by kimap/akonadi as it's not possible to RMB-click on a folder without selecting it.

C: A000257 SELECT "INBOX.Notifications.BoxeeHacks"
S: * FLAGS ( \Draft \Answered \Flagged \Deleted \Seen \Recent )
S: * OK Limited [ PERMANENTFLAGS ( \* \Draft \Answered \Flagged \Deleted \Seen )  ]
S: * 0 EXISTS
S: * 0 RECENT
S: * OK Ok [ UIDVALIDITY 1355272761  ]
S: * OK ACL [ MYRIGHTS acdilrsw  ]
S: A000257 OK Ok [ READ-WRITE  ]
C: A000258 STORE 1:* +FLAGS (\DELETED)
S: A000258 OK STORE completed.
C: A000259 EXPUNGE
S: A000259 OK EXPUNGE completed
C: A000260 DELETE "INBOX.Notifications.BoxeeHacks"
S: A000260 NO Cannot delete currently-open folder.
Comment 5 Thomas Tanghus 2013-09-18 01:11:47 UTC
Just noticed you've already got a patch Daniel - great :)
Comment 6 Daniel Vrátil 2013-09-18 07:53:52 UTC
if you are able to self-compile kdepim-runtime (stable), could you test the patch? I don't have access to any server that imposes such restriction, so I couldn't verify it really fixes the problem.
Comment 7 Thomas Tanghus 2013-09-18 10:16:51 UTC
(In reply to comment #6)
> if you are able to self-compile kdepim-runtime (stable), could you test the
> patch? I don't have access to any server that imposes such restriction, so I
> couldn't verify it really fixes the problem.

I've updated my kdepim-runtime clone. These days there are usually years between I compile anything; can you give the exact command for recompiling it, and is it enough to compile resources/imap?
Comment 8 Daniel Vrátil 2013-09-18 11:31:18 UTC
You can compile KDE/4.11 branch

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr 
cd resources/imap      # you can compile just the IMAP resource
make
sudo make install
Comment 9 Thomas Tanghus 2013-09-18 12:47:47 UTC
Hmm, I made a clean build dir, applied the patch, restarted akonadi and still get:

C: A000514 SELECT "INBOX.Notifications.BoxeeHacks"
S: * FLAGS ( \Draft \Answered \Flagged \Deleted \Seen \Recent )
S: * OK Limited [ PERMANENTFLAGS ( \* \Draft \Answered \Flagged \Deleted \Seen )  ]
S: * 0 EXISTS
S: * 0 RECENT
S: * OK Ok [ UIDVALIDITY 1355272761  ]
S: * OK ACL [ MYRIGHTS acdilrsw  ]
S: A000514 OK Ok [ READ-WRITE  ]
C: A000515 STORE 1:* +FLAGS (\DELETED)
S: A000515 OK STORE completed.
C: A000516 EXPUNGE
S: A000516 OK EXPUNGE completed
C: A000517 DELETE "INBOX.Notifications.BoxeeHacks"
S: A000517 NO Cannot delete currently-open folder.

The new resource is properly installed:
-rwxr-xr-x 1 root root 8528593 Sep 18 14:08 /usr/bin/akonadi_imap_resource

But I also got:
-rw-r--r-- 1 root root 7978566 Sep  3 20:38 /usr/lib/debug/usr/bin/akonadi_imap_resource

Does that interfere with it?
Comment 10 Daniel Vrátil 2013-09-18 13:12:50 UTC
Ooops, the IMAP resource actually uses different task than the one I fixed, sorry.

I have updated the patch in reviewboard - could you try it again please?
Comment 11 Thomas Tanghus 2013-09-18 13:52:25 UTC
Sweet:

S: A000500 OK STORE completed.
C: A000501 EXPUNGE
S: A000501 OK EXPUNGE completed
C: A000502 CLOSE
S: A000502 OK mailbox closed.
C: A000503 DELETE "INBOX.Notifications.BoxeeHacks"
S: A000503 OK Folder deleted.


Thanks a lot :)
Comment 12 Daniel Vrátil 2013-10-24 11:52:40 UTC
Git commit 4b23d9be3559c06cb65c25fa67cca2da426dcd47 by Dan Vrátil.
Committed on 24/10/2013 at 11:46.
Pushed by dvratil into branch 'KDE/4.11'.

Close IMAP mailbox before deleting it

Some IMAP servers don't allow deleting a currently SELECTed
mailbox, so we close it before DELETEing it.

REVIEW: 112786
FIXED-IN: 4.11.3

M  +70   -47   resources/imap/removecollectionrecursivetask.cpp
M  +5    -1    resources/imap/removecollectionrecursivetask.h
M  +29   -1    resources/imap/removecollectiontask.cpp
M  +5    -0    resources/imap/removecollectiontask.h

http://commits.kde.org/kdepim-runtime/4b23d9be3559c06cb65c25fa67cca2da426dcd47
Comment 13 Morten Lind 2014-01-11 23:38:51 UTC
Hi Daniel,

Good fix for deleting. However, I have the same problem with moving. My Kmail reports the response from my Courier IMAP-server: "Rename failed, server replied: A001311 NO Can't RENAME the currently-open folder". I am on Debian with kdepim-runtine v. 4.11.3-1 (testing, unstable)

It seems the same problem as the above, but I find no separate bug-report on it. Do you think you could fix this? Or should I file a separate bug-report? 

Best,
Morten
Comment 14 Daniel Vrátil 2014-01-13 10:29:12 UTC
Git commit 066efc7923640201bee5d170dfb78d0c7ecaeda4 by Dan Vrátil.
Committed on 13/01/2014 at 10:24.
Pushed by dvratil into branch 'KDE/4.12'.

Close IMAP mailbox before renaming it

Some IMAP servers don't allow renaming a currently SELECTed
mailbox, so we close it before RENAMEing it.

REVIEW: 114996
FIXED-IN: 4.12.1

M  +26   -1    resources/imap/movecollectiontask.cpp
M  +3    -0    resources/imap/movecollectiontask.h

http://commits.kde.org/kdepim-runtime/066efc7923640201bee5d170dfb78d0c7ecaeda4
Comment 15 Morten Lind 2014-06-06 08:25:06 UTC
I still get the following message when moving a folder:

"Rename failed, server replied: A003117 NO Can't RENAME the currently-open folder"

I am running libkimap4 v. 4.12, which I expect is what the bugfix mentioned:

mly13:/home/ml# aptitude versions libkimap4 
Package libkimap4:                        
p   4:4.4.5-2                                                               oldstable                                           500 
p   4:4.8.4-2                                                               stable                                              500 
i   4:4.12.4-1                                                              testing,unstable                                    500 
p   4:4.13.1-1                                                              experimental                                        1