Open Bug 357911 Opened 18 years ago Updated 2 years ago

Delete of IMAP mailbox fails for dual-use UW-imapd mailboxes (MIX folder)

Categories

(MailNews Core :: Networking: IMAP, defect)

1.8 Branch
x86
Windows XP
defect

Tracking

(Not tracked)

People

(Reporter: mozilla.bugzilla, Unassigned)

References

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0 mscha/1968.9.17
Build Identifier: Thunderbird 2.0b1pre (Windows/20061024)

I have the latest version (2006c) of the UW imapd server installed (http://www.washington.edu/imap/), and am using the new MIX mailbox format - a dual use format (can contain both messages and sub-mailboxes).
When I try to delete such a mailbox in Thunderbird, it fails to do so if it happens to be currently "selected".  There's no error message, and the mailbox appears to be gone in Thunderbird, but it will reappear after restarting Thunderbird.

This is the case both using Thunderbird 1.5 and the latest branch builds.


Reproducible: Always

Steps to Reproduce:
1. Use UW imapd 2006c, and ensure the mailbox you're testing with is in MIX format.
2. Start up Thunderbird, and open the mailbox in question.
3. Right-click on the mailbox, and choose "Delete"
4. Thunderbird appears to have deleted the mailbox (no error message)
5. Restart Thunderbird and check messages.
6. The mailbox in question is still there.

Actual Results:  
The mailbox in question is still there.

Expected Results:  
The mailbox in question should be gone, as we deleted it.

I turned on IMAP logging, and after filtering out all the cr*p it produces, here's the IMAP communication for the deletion:

    15 list "" "Mail/foo/*"
    * LIST () "/" Mail/foo/
    15 OK LIST completed
    16 delete "Mail/foo/"
    16 NO Can't lock mailbox for delete: Mail/foo/

For comparison, here's the IMAP log for deletion of an MBX format mailbox (which is not dual-use):

    15 list "" "Mail/foo/*"
    15 OK LIST completed
    16 close
    16 OK No messages deleted, so no update needed
    17 delete "Mail/foo"
    17 OK DELETE completed

Note that, in the MIX case, Thunderbird fails to close the mailbox before deleting it, while in the MBX case, it does first close it.

What appears to happen is, that, before deleting the folder in question, Thunderbird checks for any child mailboxes, and deletes those first.
An MBX mailbox can't have child mailboxes, so the "list" returns nothing.
The MIX mailbox can contain child mailboxes, and therefore, even though there aren't any child mailboxes, it does return "Mail/foo/" (note the trailing slash), which indeed matches "Mail/foo/*".
Thunderbird fails to notice that this is just our mailbox in question, with the hierarchy delimiter appended.
(Note that this is indeed the intended behaviour of UW-imap, according to the main developer, Mark Crispin.)

So, Thunderbird needs to be fixed to recognize that this is not a child mailbox, and simply ignore it, and continue to close the main mailbox and delete it.

(As an aside, it also should report that the "delete" failed, but I'll submit a separate bug for that.)

See also the corresponding email thread in the IMAP-UW mailing list: http://mailman1.u.washington.edu/pipermail/imap-uw/2006-October/000803.html (and other messages in the same thread).
Flags: blocking-thunderbird2?
This appears similar to bug 117664.
No, this is very different.  In bug 117664, the folder is deleted, but not unsubscribed.  In this bug, the folder is not deleted.
Moving to the imap bucket for triage.
Assignee: mscott → bienvenu
Status: UNCONFIRMED → NEW
Component: General → Networking: IMAP
Ever confirmed: true
Flags: blocking-thunderbird2?
Product: Thunderbird → Core
QA Contact: general → grylchan
Version: unspecified → 1.8 Branch
Some mailing list articles are found by Google search for "uw-imap mix folder". 
Following thread pointed Bug 414101(already closed as DUP of Bug 357915). 
> http://mailman2.u.washington.edu/pipermail/imap-uw/2008-January/001828.html
> (Bug 357915 provided next log)
>  14 delete "Mail/fee"
>  14 NO Mailbox Mail/fee is in use by another process
> (Bug 414101 provided next log)
>   6 delete "Trash/junk2/"
>   6 NO Can't lock mailbox for delete: Trash/junk2/
And many hit pages say "rename of MIX folder failed".

> Note that, in the MIX case, Thunderbird fails to close the mailbox
> before deleting it, while in the MBX case, it does first close it.

RFC 3501 doesn't request "close" command before "delete", "rename" etc. See example of "DELETE command". I don't think there is RFC violation by Tb.
> http://www.faqs.org/rfcs/rfc3501.html

Since IMAP "close" command invokes "Expunge at IMAP server", server possibly says  "expunge is required before delete". If MIX folder unique task is running in background, and if the task locks the folder until expunge is invoked, issue may occur. As your server says "OK ... so no update needed" in "close" response, this kind of issue may be a cause.

> dual use format (can contain both messages and sub-mailboxes)
UW-IMAP possibly locks sub-mailboxes until "close" of main mailbox(folder).

Next page says as follows.
> http://cvsweb.se.netbsd.org/cgi-bin/bsdweb.cgi/pkgsrc/mail/imap-uw/Makefile
> Updated: 23 October 2006
>(snip)
> By popular request, if a user has a mix (or other dual-use) format INBOX,
> it will no longer be listed as \NoInferiors.  It's a bad idea to depend
> upon this due to the case ambiguity issue, but it's there.
This may be relevant to "close is issued by Tb or not".

And, UW-IMAP has problm of Bug 317597. (returns \NoSelect and \NoInferiors instead of correct \Noselect and \Noinferiors). It may be relevant to "close is issued by Tb or not" too.
It may be caused by string of "\NoInferiors" in following section of RFC 3502. 
> 6.3.8.  LIST Command
>(snip)
>         If the reference argument is not a level of mailbox
>         hierarchy (that is, it is a \NoInferiors name) ...
Product: Core → MailNews Core
QA Contact: grylchan → networking.imap
Confirmed in 2.0.0.17 (Linux)

This is more annoying that I thought. As a workaround I tried to delete a folder without having it open,viz:
- left-click on undesired folder, check contents
- click on a different folder. Message pane switches to new folder contents
- right-click on undesired folder, select "delete". Confirm deletion.
- Exit Thunderbird and re-start. Undesired folder has reappeared.

I believe that Thunderbird has opened the new folder in a different thread, using a different IMAP connection (or perhaps may be showing a cached copy of the folder), but that the undesired folder is still selected in one thread.

Workaround that seems to work:
- Check undesired folder/move to Trash/etc.
- Exit Thunderbird
- Restart Thunderbird. Do NOT select the undesired folder.
- Select "empty Trash" or right-click undesired folder and select "Delete"
-> directory disappears

There is another issue with uw imapd - when the folder is successfully deleted, imapd implicitly unsubscribes it. TB issues an unsubscribe command anyway, to which imapd replies "NO". TB ignores this status and deletes the icon. This would be OK except that there is a bug in imapd where it does not actually remove the folder from the IMAP subscription list after it is deleted. So when the user logs in again with TB, the deleted folder magically reappears but cannot be selected. It can, however, be unsubscribed from, which fixes it.

This seems another instance of TB ignoring IMAP status returns and pretending things are fine when the server has said that they aren't.
Summary: Delete of IMAP mailbox fails for dual-use UW-imapd mailboxes → Delete of IMAP mailbox fails for dual-use UW-imapd mailboxes (MIX folder)
Assignee: mozilla → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.