diff src/lib-storage/index/dbox-single/sdbox-sync.c @ 19168:e29d2f7fe53f

lib-storage: Update mailbox vsize header on save/copy/expunge. This allows always efficiently looking up maiboxes' vsizes after they're initially calculated. The expunge handling is unfortunately done currently in quota handling code, so it works only if quota is enabled. Ideally this would be solved in v2.3 with some lib-storage core changes.
author Timo Sirainen <tss@iki.fi>
date Mon, 21 Sep 2015 16:32:27 +0300
parents f78bd5be4e47
children 0f22db71df7a
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-single/sdbox-sync.c	Mon Sep 21 16:24:30 2015 +0300
+++ b/src/lib-storage/index/dbox-single/sdbox-sync.c	Mon Sep 21 16:32:27 2015 +0300
@@ -216,15 +216,12 @@
 	sync_flags |= MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES;
 
 	for (i = 0;; i++) {
-		ret = mail_index_sync_begin(mbox->box.index,
-					    &ctx->index_sync_ctx,
-					    &ctx->sync_view, &ctx->trans,
-					    sync_flags);
+		ret = index_storage_expunged_sync_begin(&mbox->box,
+				&ctx->index_sync_ctx, &ctx->sync_view,
+				&ctx->trans, sync_flags);
 		if (mail_index_reset_fscked(mbox->box.index))
 			sdbox_set_mailbox_corrupted(&mbox->box);
 		if (ret <= 0) {
-			if (ret < 0)
-				mailbox_set_index_error(&mbox->box);
 			array_free(&ctx->expunged_uids);
 			i_free(ctx);
 			*ctx_r = NULL;
@@ -255,6 +252,7 @@
 		}
 		mail_index_sync_rollback(&ctx->index_sync_ctx);
 		if (ret < 0) {
+			index_storage_expunging_deinit(&ctx->mbox->box);
 			array_free(&ctx->expunged_uids);
 			i_free(ctx);
 			return -1;
@@ -274,6 +272,7 @@
 
 	if (success) {
 		mail_index_view_ref(ctx->sync_view);
+
 		if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
 			mailbox_set_index_error(&ctx->mbox->box);
 			ret = -1;
@@ -285,6 +284,7 @@
 		mail_index_sync_rollback(&ctx->index_sync_ctx);
 	}
 
+	index_storage_expunging_deinit(&ctx->mbox->box);
 	array_free(&ctx->expunged_uids);
 	i_free(ctx);
 	return ret;