]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Move backend code to a common index_storage_save_abort_last()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 28 Apr 2017 11:06:43 +0000 (14:06 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 28 Apr 2017 11:06:43 +0000 (14:06 +0300)
src/lib-storage/index/dbox-multi/mdbox-save.c
src/lib-storage/index/dbox-single/sdbox-save.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/index-storage.h
src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/index/mbox/mbox-save.c

index db50757cdd269b6025af9c84a3441276d91029e5..86fdb7ec261b01606af9134889b1040c40656cf5 100644 (file)
@@ -216,8 +216,7 @@ static int mdbox_save_finish_write(struct mail_save_context *_ctx)
        i_stream_unref(&ctx->ctx.input);
 
        if (ctx->ctx.failed) {
-               mail_index_expunge(ctx->ctx.trans, ctx->ctx.seq);
-               mail_cache_transaction_reset(ctx->ctx.ctx.transaction->cache_trans);
+               index_storage_save_abort_last(&ctx->ctx.ctx, ctx->ctx.seq);
                mdbox_map_append_abort(ctx->append_ctx);
                array_delete(&ctx->mails, array_count(&ctx->mails) - 1, 1);
                return -1;
index 95ff5c256c9df729261267c6cea2c10941063c77..feb2fd28c12ee2774e5ffed8e81e14a964cafe4a 100644 (file)
@@ -195,8 +195,7 @@ static int dbox_save_finish_write(struct mail_save_context *_ctx)
        } T_END;
 
        if (ctx->ctx.failed) {
-               mail_index_expunge(ctx->ctx.trans, ctx->ctx.seq);
-               mail_cache_transaction_reset(ctx->ctx.ctx.transaction->cache_trans);
+               index_storage_save_abort_last(&ctx->ctx.ctx, ctx->ctx.seq);
                dbox_file_append_rollback(&ctx->append_ctx);
                dbox_file_unlink(*files);
                dbox_file_unref(files);
index 4bb3f6f4cf959173aff5dccbecb13722a3d1361a..8f9189a74e6904366457e4552e795e9b927cb173 100644 (file)
@@ -1115,3 +1115,11 @@ int index_storage_save_continue(struct mail_save_context *ctx,
        }
        return 0;
 }
+
+void index_storage_save_abort_last(struct mail_save_context *ctx, uint32_t seq)
+{
+       mail_index_expunge(ctx->transaction->itrans, seq);
+       /* currently we can't just drop pending cache updates for this one
+          specific record, so we'll reset the whole cache transaction. */
+       mail_cache_transaction_reset(ctx->transaction->cache_trans);
+}
index 62d106b3a211df6d7f1a49e861f0e6a5f32788f8..ff5ed4c1cf8554d2e393213627ae2908d5ef5fd0 100644 (file)
@@ -176,5 +176,6 @@ void index_storage_expunging_deinit(struct mailbox *box);
 int index_storage_save_continue(struct mail_save_context *ctx,
                                struct istream *input,
                                struct mail *cache_dest_mail);
+void index_storage_save_abort_last(struct mail_save_context *ctx, uint32_t seq);
 
 #endif
index 9f88cd87d69ad4add8a731a4b3cbbac60a13782f..3266161a6a66067d2d364535cbda12cff7bba864 100644 (file)
@@ -501,10 +501,7 @@ static void maildir_save_remove_last_filename(struct maildir_save_context *ctx)
 {
        struct maildir_filename **fm;
 
-       mail_index_expunge(ctx->trans, ctx->seq);
-       /* currently we can't just drop pending cache updates for this one
-          specific record, so we'll reset the whole cache transaction. */
-       mail_cache_transaction_reset(ctx->ctx.transaction->cache_trans);
+       index_storage_save_abort_last(&ctx->ctx, ctx->seq);
        ctx->seq--;
 
        for (fm = &ctx->files; (*fm)->next != NULL; fm = &(*fm)->next) ;
index f364658734370fb84eea988b8f59b566980922cc..050653495f1f250785c5e844e08403bd61905363 100644 (file)
@@ -688,11 +688,7 @@ int mbox_save_finish(struct mail_save_context *_ctx)
        }
 
        if (ctx->seq != 0 && ctx->failed) {
-               mail_index_expunge(ctx->trans, ctx->seq);
-               /* currently we can't just drop pending cache updates for this
-                  one specific record, so we'll reset the whole cache
-                  transaction. */
-               mail_cache_transaction_reset(ctx->ctx.transaction->cache_trans);
+               index_storage_save_abort_last(&ctx->ctx, ctx->seq);
        }
        index_save_context_free(_ctx);
        return ctx->failed ? -1 : 0;