implemented via save, and the save_*() methods want to access the
source mail. */
struct mail *copy_src_mail;
+ /* Set during mailbox_move() and mailbox_save_begin_replace(). This
+ is made available for the quota plugin to allow accounting for the
+ size of the mail that is being expunged as part of the MOVE and
+ REPLACE commands, respectively. */
+ struct mail *expunged_mail;
/* data that changes for each saved mail */
struct mail_save_data data;
return 0;
}
+int mailbox_save_begin_replace(struct mail_save_context **ctx,
+ struct istream *input,
+ struct mail *replaced)
+{
+ (*ctx)->expunged_mail = replaced;
+ return mailbox_save_begin(ctx, input);
+}
+
int mailbox_save_continue(struct mail_save_context *ctx)
{
int ret;
if (pvt_flags != 0)
mailbox_save_add_pvt_flags(t, pvt_flags);
t->save_count++;
+ if (ctx->expunged_mail != NULL)
+ mail_expunge(ctx->expunged_mail);
}
mailbox_save_context_reset(ctx, TRUE);
i_assert(!ctx->moving);
ctx->moving = TRUE;
+ ctx->expunged_mail = mail;
T_BEGIN {
if ((ret = mailbox_copy_int(_ctx, mail)) == 0)
mail_expunge(mail);
i_stream_read() and calling mailbox_save_continue() as long as there's
more input. */
int mailbox_save_begin(struct mail_save_context **ctx, struct istream *input);
+/* Begin saving the message that replaces the provided mail (which may reside
+ in another mailbox altogether). The replaced mail is expunged implicitly
+ when saving the message succeeds at mailbox_save_finish(). In all other
+ respects this function behaves the same as mailbox_save_begin(). */
+int mailbox_save_begin_replace(struct mail_save_context **ctx,
+ struct istream *input,
+ struct mail *replaced);
int mailbox_save_continue(struct mail_save_context *ctx);
int mailbox_save_finish(struct mail_save_context **ctx);
void mailbox_save_cancel(struct mail_save_context **ctx);