Commit 7317a04a 7317a04a5dee2d5c585206d12866d591dce0bf1a by Sergey Poznyakoff

Fix imap appends for AMD mailboxes.

* imap4d/append.c (imap4d_append0): Provide size method for the message
stream.
* imap4d/select.c (imap4d_select0): Call mu_mailbox_create_default.
* mailbox/amd.c (amd_append_message): Improve error checking.
1 parent f4456475
2008-08-08 Sergey Poznyakoff <gray@gnu.org.ua>
Fix imap appends for AMD mailboxes.
* imap4d/append.c (imap4d_append0): Provide size method for the
message stream.
* imap4d/select.c (imap4d_select0): Call mu_mailbox_create_default.
* mailbox/amd.c (amd_append_message): Improve error checking.
2008-08-07 Sergey Poznyakoff <gray@gnu.org.ua>
* imap4d/create.c: Rewrite to create mailboxes honoring
......
......@@ -87,6 +87,16 @@ _append_sender (mu_envelope_t envelope, char *buf, size_t len, size_t *pnwrite)
return 0;
}
static int
_append_size (mu_message_t msg, size_t *psize)
{
mu_stream_t str;
int status = mu_message_get_stream (msg, &str);
if (status == 0)
status = mu_stream_size (str, psize);
return status;
}
int
imap4d_append0 (mu_mailbox_t mbox, int flags, char *text)
{
......@@ -127,6 +137,7 @@ imap4d_append0 (mu_mailbox_t mbox, int flags, char *text)
mu_stream_write (stream, text, strlen (text), len, &len);
mu_message_set_stream (msg, stream, &tm);
mu_message_set_size (msg, _append_size, &tm);
mu_envelope_create (&env, msg);
mu_envelope_set_date (env, _append_date, msg);
......
......@@ -63,7 +63,7 @@ imap4d_select0 (struct imap4d_command *command, char *arg, int flags)
if (!mailbox_name)
return util_finish (command, RESP_NO, "Couldn't open mailbox");
if ((status = mu_mailbox_create (&mbox, mailbox_name)) == 0
if ((status = mu_mailbox_create_default (&mbox, mailbox_name)) == 0
&& (status = mu_mailbox_open (mbox, flags)) == 0)
{
select_flags = flags;
......
......@@ -782,6 +782,12 @@ amd_append_message (mu_mailbox_t mailbox, mu_message_t msg)
mhm->message = msg;
status = _amd_message_save (amd, mhm, 0);
if (status)
{
free (mhm);
return status;
}
mhm->message = NULL;
/* Insert and re-scan the message */
status = _amd_message_insert (amd, mhm);
......