save->flags = pvt_flags;
}
-static void mailbox_save_context_reset(struct mail_save_context *ctx)
+static void
+mailbox_save_context_reset(struct mail_save_context *ctx, bool success)
{
i_assert(!ctx->unfinished);
if (!ctx->copying_or_moving) {
- /* we're finishing a save (not copy/move) */
+ /* we're finishing a save (not copy/move). Note that we could
+ have come here also from mailbox_save_cancel(), in which
+ case ctx->saving may be FALSE. */
i_assert(!ctx->copying_via_save);
- i_assert(ctx->saving);
+ i_assert(ctx->saving || !success);
ctx->saving = FALSE;
} else {
i_assert(ctx->copying_via_save);
}
if (keywords != NULL)
mailbox_keywords_unref(&keywords);
- mailbox_save_context_reset(ctx);
+ mailbox_save_context_reset(ctx, TRUE);
return ret;
}
mail = (struct mail_private *)ctx->dest_mail;
mail->v.close(&mail->mail);
}
- mailbox_save_context_reset(ctx);
+ mailbox_save_context_reset(ctx, FALSE);
}
struct mailbox_transaction_context *