/* mailbox_save_alloc() called, but finish/cancel not.
the same context is usually returned by the backends for reuse. */
unsigned int unfinished:1;
+ /* mailbox_save_finish() or mailbox_copy() is being called. */
+ unsigned int finishing:1;
/* mail was copied using saving */
unsigned int copying_via_save:1;
/* mail is being saved, not copied */
}
*_ctx = NULL;
+ ctx->finishing = TRUE;
ret = t->box->v.save_finish(ctx);
+ ctx->finishing = FALSE;
+
if (ret == 0 && !copying_via_save) {
if (pvt_flags != 0)
mailbox_save_add_pvt_flags(t, pvt_flags);
*_ctx = NULL;
ctx->transaction->box->v.save_cancel(ctx);
- if (keywords != NULL)
+ if (keywords != NULL && !ctx->finishing)
mailbox_keywords_unref(&keywords);
if (ctx->dest_mail != NULL) {
/* the dest_mail is no longer valid. if we're still saving
mailbox_save_cancel(&ctx);
return -1;
}
+ ctx->finishing = TRUE;
ret = t->box->v.copy(ctx, backend_mail);
+ ctx->finishing = FALSE;
if (ret == 0) {
if (pvt_flags != 0)
mailbox_save_add_pvt_flags(t, pvt_flags);