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 ...@@ -28,12 +28,19 @@ int
28 imap4d_close (struct imap4d_command *command, char *arg ARG_UNUSED) 28 imap4d_close (struct imap4d_command *command, char *arg ARG_UNUSED)
29 { 29 {
30 const char *msg = NULL; 30 const char *msg = NULL;
31 int status = mailbox_flush (mbox, 1); 31 int status, flags;
32
33 mailbox_get_flags (mbox, &flags);
34 if ((flags & MU_STREAM_READ) == 0)
35 {
36 status = mailbox_flush (mbox, 1);
32 if (status) 37 if (status)
33 { 38 {
34 syslog (LOG_ERR, _("flushing mailbox failed: %s"), mu_strerror (status)); 39 syslog (LOG_ERR,
40 _("flushing mailbox failed: %s"), mu_strerror (status));
35 msg = "flushing mailbox failed"; 41 msg = "flushing mailbox failed";
36 } 42 }
43 }
37 44
38 /* No messages are removed, and no error is given, if the mailbox is 45 /* No messages are removed, and no error is given, if the mailbox is
39 selected by an EXAMINE command or is otherwise selected read-only. */ 46 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) ...@@ -46,6 +53,6 @@ imap4d_close (struct imap4d_command *command, char *arg ARG_UNUSED)
46 mailbox_destroy (&mbox); 53 mailbox_destroy (&mbox);
47 54
48 if (msg) 55 if (msg)
49 util_finish (command, RESP_NO, msg); 56 return util_finish (command, RESP_NO, msg);
50 return util_finish (command, RESP_OK, "Completed"); 57 return util_finish (command, RESP_OK, "Completed");
51 } 58 }
......