Commit 73218069 73218069f98318f84c77ffc7ac0c89230dd457e0 by Sergey Poznyakoff

Do not attempt to flush a mailbox opened in read-only mode.

1 parent 69ad872f
......@@ -28,12 +28,19 @@ int
imap4d_close (struct imap4d_command *command, char *arg ARG_UNUSED)
{
const char *msg = NULL;
int status = mailbox_flush (mbox, 1);
int status, flags;
mailbox_get_flags (mbox, &flags);
if ((flags & MU_STREAM_READ) == 0)
{
status = mailbox_flush (mbox, 1);
if (status)
{
syslog (LOG_ERR, _("flushing mailbox failed: %s"), mu_strerror (status));
syslog (LOG_ERR,
_("flushing mailbox failed: %s"), mu_strerror (status));
msg = "flushing mailbox failed";
}
}
/* No messages are removed, and no error is given, if the mailbox is
selected by an EXAMINE command or is otherwise selected read-only. */
......@@ -46,6 +53,6 @@ imap4d_close (struct imap4d_command *command, char *arg ARG_UNUSED)
mailbox_destroy (&mbox);
if (msg)
util_finish (command, RESP_NO, msg);
return util_finish (command, RESP_NO, msg);
return util_finish (command, RESP_OK, "Completed");
}
......