# HG changeset patch # User Timo Sirainen # Date 1148977880 -10800 # Node ID ca5008de292125549031c46ca268c7f559f866f7 # Parent 19a0864deb4e5e40c524b9b8f75c278afaa9c319 If we're synchronizing a view (and not index itself) from transaction log, give a different error message and don't mark the file corrupted. diff -r 19a0864deb4e -r ca5008de2921 src/lib-index/mail-index-sync-ext.c --- a/src/lib-index/mail-index-sync-ext.c Tue May 30 11:26:48 2006 +0300 +++ b/src/lib-index/mail-index-sync-ext.c Tue May 30 11:31:20 2006 +0300 @@ -352,13 +352,13 @@ if (u->ext_id != (uint32_t)-1 && (!array_is_created(&map->extensions) || u->ext_id >= array_count(&map->extensions))) { - mail_transaction_log_view_set_corrupted(ctx->view->log_view, + mail_index_sync_set_corrupted(ctx, "Extension introduction for unknown id %u", u->ext_id); return -1; } if (u->ext_id == (uint32_t)-1 && u->name_size == 0) { - mail_transaction_log_view_set_corrupted(ctx->view->log_view, + mail_index_sync_set_corrupted(ctx, "Extension introduction without id or name"); return -1; } @@ -454,7 +454,7 @@ uint32_t i; if (ctx->cur_ext_id == (uint32_t)-1) { - mail_transaction_log_view_set_corrupted(view->log_view, + mail_index_sync_set_corrupted(ctx, "Extension reset without intro prefix"); return -1; } @@ -490,7 +490,7 @@ const struct mail_index_ext *ext; if (ctx->cur_ext_id == (uint32_t)-1) { - mail_transaction_log_view_set_corrupted(ctx->view->log_view, + mail_index_sync_set_corrupted(ctx, "Extension header update without intro prefix"); return -1; } diff -r 19a0864deb4e -r ca5008de2921 src/lib-index/mail-index-sync-keywords.c --- a/src/lib-index/mail-index-sync-keywords.c Tue May 30 11:26:48 2006 +0300 +++ b/src/lib-index/mail-index-sync-keywords.c Tue May 30 11:31:20 2006 +0300 @@ -260,7 +260,7 @@ seqset_offset += 4 - (seqset_offset % 4); if (seqset_offset > hdr->size) { - mail_transaction_log_view_set_corrupted(ctx->view->log_view, + mail_index_sync_set_corrupted(ctx, "Keyword header ended unexpectedly"); return -1; } @@ -269,7 +269,7 @@ end = CONST_PTR_OFFSET(rec, hdr->size); if (uid == end) { - mail_transaction_log_view_set_corrupted(ctx->view->log_view, + mail_index_sync_set_corrupted(ctx, "Keyword sequence list empty"); return -1; } @@ -306,9 +306,8 @@ while (uid+2 <= end) { if (uid[0] > uid[1] || uid[0] == 0) { - mail_transaction_log_view_set_corrupted( - ctx->view->log_view, - "Keyword record UIDs are broken"); + mail_index_sync_set_corrupted(ctx, + "Keyword record UIDs are broken"); return -1; } diff -r 19a0864deb4e -r ca5008de2921 src/lib-index/mail-index-sync-private.h --- a/src/lib-index/mail-index-sync-private.h Tue May 30 11:26:48 2006 +0300 +++ b/src/lib-index/mail-index-sync-private.h Tue May 30 11:31:20 2006 +0300 @@ -96,4 +96,7 @@ const struct mail_transaction_header *hdr, const struct mail_transaction_keyword_reset *r); +void mail_index_sync_set_corrupted(struct mail_index_sync_map_ctx *ctx, + const char *fmt, ...) __attr_format__(2, 3); + #endif diff -r 19a0864deb4e -r ca5008de2921 src/lib-index/mail-index-sync-update.c --- a/src/lib-index/mail-index-sync-update.c Tue May 30 11:26:48 2006 +0300 +++ b/src/lib-index/mail-index-sync-update.c Tue May 30 11:31:20 2006 +0300 @@ -131,7 +131,7 @@ unsigned int i, expunge_handlers_count; if (e->uid1 > e->uid2 || e->uid1 == 0) { - mail_transaction_log_view_set_corrupted(ctx->view->log_view, + mail_index_sync_set_corrupted(ctx, "Invalid UID range in expunge (%u .. %u)", e->uid1, e->uid2); return -1; @@ -228,7 +228,7 @@ void *dest; if (rec->uid < map->hdr.next_uid) { - mail_transaction_log_view_set_corrupted(view->log_view, + mail_index_sync_set_corrupted(ctx, "Append with UID %u, but next_uid = %u", rec->uid, map->hdr.next_uid); return -1; @@ -277,7 +277,7 @@ uint32_t idx, seq1, seq2; if (u->uid1 > u->uid2 || u->uid1 == 0) { - mail_transaction_log_view_set_corrupted(ctx->view->log_view, + mail_index_sync_set_corrupted(ctx, "Invalid UID range in flag update (%u .. %u)", u->uid1, u->uid2); return -1; @@ -331,7 +331,7 @@ if (u->offset >= map->hdr.base_header_size || u->offset + u->size > map->hdr.base_header_size) { - mail_transaction_log_view_set_corrupted(ctx->view->log_view, + mail_index_sync_set_corrupted(ctx, "Header update outside range: %u + %u > %u", u->offset, u->size, map->hdr.base_header_size); return -1; @@ -551,8 +551,7 @@ unsigned int record_size; if (ctx->cur_ext_id == (uint32_t)-1) { - mail_transaction_log_view_set_corrupted( - ctx->view->log_view, + mail_index_sync_set_corrupted(ctx, "Extension record update update " "without intro prefix"); ret = -1; diff -r 19a0864deb4e -r ca5008de2921 src/lib-index/mail-index-sync.c --- a/src/lib-index/mail-index-sync.c Tue May 30 11:26:48 2006 +0300 +++ b/src/lib-index/mail-index-sync.c Tue May 30 11:31:20 2006 +0300 @@ -735,3 +735,24 @@ return FALSE; } } + +void mail_index_sync_set_corrupted(struct mail_index_sync_map_ctx *ctx, + const char *fmt, ...) +{ + const char *error; + va_list va; + + va_start(va, fmt); + t_push(); + error = t_strdup_vprintf(fmt, va); + if (ctx->type == MAIL_INDEX_SYNC_HANDLER_INDEX) { + mail_transaction_log_view_set_corrupted(ctx->view->log_view, + "%s", error); + } else { + mail_index_set_error(ctx->view->index, + "View synchronization from transaction log failed: %s", + error); + } + t_pop(); + va_end(va); +}