# HG changeset patch # User Timo Sirainen # Date 1148977608 -10800 # Node ID 19a0864deb4e5e40c524b9b8f75c278afaa9c319 # Parent c8af5a2492c5ec69282c1ce6653114e2eb49a737 If syncing from transaction log fails, fallback to re-reading the index file (and more importantly, try to avoid crashing in assert..) diff -r c8af5a2492c5 -r 19a0864deb4e src/lib-index/mail-index.c --- a/src/lib-index/mail-index.c Tue May 30 11:25:24 2006 +0300 +++ b/src/lib-index/mail-index.c Tue May 30 11:26:48 2006 +0300 @@ -809,7 +809,7 @@ uoff_t prev_offset, max_offset; size_t pos; int ret; - bool skipped, check_ext_offsets; + bool skipped, check_ext_offsets, broken; if (sync_to_index) { /* read the real log position where we are supposed to be @@ -865,7 +865,7 @@ mail_index_sync_map_init(&sync_map_ctx, view, MAIL_INDEX_SYNC_HANDLER_VIEW); - check_ext_offsets = TRUE; + check_ext_offsets = TRUE; broken = FALSE; while ((ret = mail_transaction_log_view_next(log_view, &thdr, &tdata, &skipped)) > 0) { if ((thdr->type & MAIL_TRANSACTION_EXTERNAL) != 0 && @@ -876,10 +876,13 @@ } if (mail_index_sync_record(&sync_map_ctx, thdr, tdata) < 0) { - ret = -1; + ret = 0; + broken = TRUE; break; } } + if (ret == 0 && !broken) + ret = 1; mail_transaction_log_view_get_prev_pos(log_view, &prev_seq, &prev_offset); @@ -897,7 +900,7 @@ *map = index->map; index->map = NULL; - if (sync_to_index) { + if (sync_to_index && ret > 0) { /* make sure we did everything right. note that although the message counts should be equal, the flag counters may not */ i_assert(hdr.messages_count == (*map)->hdr.messages_count); @@ -906,7 +909,7 @@ i_assert(hdr.log_file_ext_offset == (*map)->hdr.log_file_ext_offset); } - return ret < 0 ? -1 : 1; + return ret; } static int mail_index_read_map_with_retry(struct mail_index *index,