GNOME Bugzilla – Bug 747459
[CLIENTBUG] Status on selected mailbox completed.
Last modified: 2015-04-08 10:11:32 UTC
According to the Dovecot folks, issueing `STATUS` when a mailbox is selected is incorrect [1]. > On Sat, 16 Apr 2005, Mike Schmidt wrote: > Can someone tell me what the CLIENT BUG references mean in the status report? > > It means that you did a STATUS command on the selected (opened) mailbox; a completely unnecessary and wasteful operation which could also have additional severe negative consequences. > > When you have a mailbox selected, the IMAP state already has all the data that a STATUS command could return. The STATUS command is to the be used only to get this data from a mailbox which is *NOT* selected. > > This has been shown to be an area which many novices fail to understand; many seem to believe (incorrectly) that you have to do a STATUS to get updated mailbox state. Learning how IMAP really works in this case is likely to help client authors understand IMAP in other cases, hence this is a mistake that I felt is important to correct. > > This is a transcript of the IMAP status operation. The client is based on c-client, running in Windows XP, and the server is uw-imapd running over a TLS connection (on Linux) > > If the client was written using c-client, then you did a mail_status() call on a mailbox name when you already had a perfectly good MAILSTREAM with all the data you need from a mail_open() call. > > The correct procedure is to get the data from the MAILSTREAM. For example, in your case of getting: > (MESSAGES RECENT UNSEEN UIDNEXT UIDVALIDITY) > you should use > stream->nmsgs > stream->recent > either do a mail_search() for unseen and count the number of > responses coming back, or if all message metadata is in > c-client's cache just count the number of messages which have > !mail_elt(stream,i)->seen, for i=1 to nmsgs. > stream->uid_last+1 > stream->uid_validity > > The simplest way to get the RECENT count is: > mail_fetch_fast (stream,"1:*",NIL); > for (i = 1, j = 0; i <= stream->nmsgs; ++i) > if (!mail_elt (stream,i)->seen) ++j; > However that mail_fetch_fast() should only be done once in any session. If you've already gotten all the message metadata once you don't need to get it again. IMAP automatically updates it for you. > > A STATUS command forces the IMAP server to do its open mail_open() call get the data from the resulting MAILSTREAM, then close it. But it already has done a mail_open() on that mailbox, as has your client. Hence the waste. The multiple opens can also cause other problems. > > Thanks very much. This certainly looks pretty confusing to me, but I' m just getting started writing a client using c-client. > > The message is obnoxious for a reason; it's to get the client author's attention and get him to ask "what's going on?" (and hopefully the explanation will convince him to do the right thing instead of abusing STATUS). So, in this case, it worked as designed. > > If there's anything unclear about any of the above, please ask. I'm not sure if the above answer adequately explains "why" as opposed to "what". > > Also, please don't feel bad; you have lots of company in having made this mistake. You responded intelligently as well (ask and find out what's wrong); too many people just try to hide the message and never fix what their client is doing wrong... :-( > > -- Mark -- [1] http://osdir.com/ml/mail.imap.uw.c-client/2005-04/msg00028.html
True, true. *** This bug has been marked as a duplicate of bug 621765 ***
Thank you. Searching for that message in Bugzilla there were no results, so thank you for telling me about bug 621765.