sdbox-mail.c revision 804fa3f03bd9170272168a5ad214053bbe3160c7
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainen/* Copyright (c) 2007-2017 Dovecot authors, see the included COPYING file */
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainenstatic void sdbox_mail_set_expunged(struct dbox_mail *mail)
23878bd03d1de531e3261a25598beec621351910Timo Sirainen if (mail_index_is_expunged(_mail->transaction->view, _mail->seq)) {
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen mail_storage_set_critical(_mail->box->storage,
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen "dbox %s: Unexpectedly lost uid=%u",
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainenstatic int sdbox_mail_file_set(struct dbox_mail *mail)
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)_mail->box;
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen /* already set */
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen mail->open_file = sdbox_file_init(mbox, _mail->uid);
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen /* mail is being saved in this transaction */
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen /* it doesn't have input stream yet */
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen ret = dbox_file_open(mail->open_file, &deleted);
23878bd03d1de531e3261a25598beec621351910Timo Sirainen mail_storage_set_critical(_mail->box->storage,
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainen "dbox %s: Unexpectedly lost mail being saved",
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainensdbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
0779e926687b319fe1bcc0f1010ba7f88023e789Timo Sirainen const char **value_r)
bd417d416988d11a6b555b9aa57779e7ed976951Timo Sirainen struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)_mail->box;
0779e926687b319fe1bcc0f1010ba7f88023e789Timo Sirainen _mail->transaction->stats.fstat_lookup_count++;
0779e926687b319fe1bcc0f1010ba7f88023e789Timo Sirainen if (dbox_file_stat(mail->open_file, &st) < 0) {
97437f768d1a3e6134fed1971202803fd250eef2Timo Sirainen *value_r = p_strdup_printf(mail->imail.mail.data_pool, "%lu",
b8b085f7bc6f1c0367802a9f00062bbbd981690dTimo Sirainen if (!dbox_header_have_flag(&mbox->box, mbox->hdr_ext_id,
23878bd03d1de531e3261a25598beec621351910Timo Sirainen if (!dbox_header_have_flag(&mbox->box, mbox->hdr_ext_id,
ecbbdf594f9329fc15a182bd6c7c4a7fb144ed74Timo Sirainen return dbox_mail_get_special(_mail, field, value_r);
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainenint sdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r,
bool deleted;
int ret;
if (ret < 0)
if (ret == 0) {
if (deleted) {
*offset_r = 0;
NULL,