int ret = ctx->failed ? -1 : 0;
*_ctx = NULL;
- if (ret == 0) {
- if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
- mailbox_set_index_error(&ctx->mbox->box);
- ret = -1;
- }
- } else {
- mail_index_sync_rollback(&ctx->index_sync_ctx);
+ /* Commit the transaction even if we failed. This is important, because
+ during the sync delayed_sync_trans points to the sync transaction.
+ Even if the syncing doesn't fully succeed, we don't want to lose
+ changes in delayed_sync_trans. */
+ if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
+ mailbox_set_index_error(&ctx->mbox->box);
+ ret = -1;
}
if (ctx->mbox->sync_gmail_pop3_search_tag != NULL) {
mailbox_set_critical(&ctx->mbox->box,