Mercurial > dovecot > core-2.2
changeset 4613:84ee1092021f HEAD
mail_set_uid() now returns 0 = expunged, 1 = ok.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 17 Sep 2006 20:49:02 +0300 |
parents | 2c033ffc8f6f |
children | bdfc03178263 |
files | src/imap/imap-thread.c src/lib-storage/index/index-mail.c src/lib-storage/mail-storage.h |
diffstat | 3 files changed, 37 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-thread.c Sun Sep 17 20:28:36 2006 +0300 +++ b/src/imap/imap-thread.c Sun Sep 17 20:49:02 2006 +0300 @@ -229,9 +229,14 @@ uint32_t msgid_crc32, const char **msgid_r) { const char *msgids, *msgid, *found_msgid = NULL; + int ret; - if (mail_set_uid(ctx->tmp_mail, parent_uid) < 0) + if ((ret = mail_set_uid(ctx->tmp_mail, parent_uid)) < 0) return -1; + if (ret == 0) { + *msgid_r = NULL; + return 0; + } msgids = mail_get_first_header(ctx->tmp_mail, HDR_IN_REPLY_TO); msgid = msgids == NULL ? NULL : message_id_get_next(&msgids); @@ -299,7 +304,7 @@ if (rec->rec.uid != 0) { /* we can get the Message-ID directly */ - if (mail_set_uid(ctx->tmp_mail, rec->rec.uid) < 0) + if (mail_set_uid(ctx->tmp_mail, rec->rec.uid) <= 0) return NULL; msgids = mail_get_first_header(ctx->tmp_mail, HDR_MESSAGE_ID); @@ -1325,7 +1330,7 @@ uid = rec->rec.uid; } - if (mail_set_uid(ctx->tmp_mail, roots[i]->uid) == 0) { + if (mail_set_uid(ctx->tmp_mail, roots[i]->uid) > 0) { t_push(); subject = mail_get_first_header(ctx->tmp_mail, HDR_SUBJECT);
--- a/src/lib-storage/index/index-mail.c Sun Sep 17 20:28:36 2006 +0300 +++ b/src/lib-storage/index/index-mail.c Sun Sep 17 20:49:02 2006 +0300 @@ -826,7 +826,7 @@ const struct mail_index_header *hdr; pool_t pool; - pool = pool_alloconly_create("mail", 512); + pool = pool_alloconly_create("mail", 1024); mail = p_new(pool, struct index_mail, 1); mail->mail.pool = pool; array_create(&mail->mail.module_contexts, pool, sizeof(void *), 5); @@ -857,6 +857,22 @@ i_stream_destroy(&mail->data.filter_stream); } +static void index_mail_reset(struct index_mail *mail) +{ + struct index_mail_data *data = &mail->data; + + index_mail_close(mail); + + memset(data, 0, sizeof(*data)); + p_clear(mail->data_pool); + + data->virtual_size = (uoff_t)-1; + data->physical_size = (uoff_t)-1; + data->save_date = (time_t)-1; + data->received_date = (time_t)-1; + data->sent_date.time = (time_t)-1; +} + static void check_envelope(struct index_mail *mail) { unsigned int cache_field_envelope = @@ -903,18 +919,10 @@ return -1; } - index_mail_close(mail); - - memset(data, 0, sizeof(*data)); - p_clear(mail->data_pool); + index_mail_reset(mail); data->rec = rec; data->seq = seq; - data->virtual_size = (uoff_t)-1; - data->physical_size = (uoff_t)-1; - data->save_date = (time_t)-1; - data->received_date = (time_t)-1; - data->sent_date.time = (time_t)-1; if (!index_mail_get_fixed_field(mail, MAIL_CACHE_FLAGS, &data->cache_flags, @@ -1019,7 +1027,16 @@ uid, uid, &seq, &seq) < 0) return -1; - return index_mail_set_seq(_mail, seq); + if (seq == 0) { + index_mail_reset(mail); + mail->mail.mail.uid = uid; + mail->mail.mail.expunged = TRUE; + return 0; + } + + if (index_mail_set_seq(_mail, seq) < 0) + return -1; + return 1; } void index_mail_free(struct mail *_mail)
--- a/src/lib-storage/mail-storage.h Sun Sep 17 20:28:36 2006 +0300 +++ b/src/lib-storage/mail-storage.h Sun Sep 17 20:49:02 2006 +0300 @@ -441,6 +441,7 @@ struct mailbox_header_lookup_ctx *wanted_headers); void mail_free(struct mail **mail); int mail_set_seq(struct mail *mail, uint32_t seq); +/* Returns -1 if error, 0 if UID has already been expunged, 1 if ok */ int mail_set_uid(struct mail *mail, uint32_t uid); /* Get the Date-header of the mail. Timezone is in minutes.