ARRAY_TYPE(seq_range) added_uids;
unsigned int failed:1;
+ unsigned int corrupted:1;
};
struct mail_thread_mailbox {
static void mail_thread_clear(struct mail_thread_context *ctx);
static int
-mail_strmap_rec_get_msgid(struct mail *mail,
+mail_strmap_rec_get_msgid(struct mail_thread_context *ctx,
const struct mail_index_strmap_rec *rec,
const char **msgid_r)
{
+ struct mail *mail = ctx->tmp_mail;
const char *msgids = NULL, *msgid;
unsigned int n = 0;
int ret;
/* get the nth message-id */
msgid = message_id_get_next(&msgids);
if (msgid != NULL) {
- for (; n > 0 && *msgids != '\0'; n--)
+ for (; n > 0; n--)
msgid = message_id_get_next(&msgids);
}
if (msgid == NULL) {
- /* shouldn't have happened */
+ /* shouldn't have happened, probably corrupted */
mail_storage_set_critical(mail->box->storage,
- "Threading in %s UID %u lost Message ID %u",
+ "Corrupted thread index for mailbox %s: "
+ "UID %u lost Message ID %u",
mail->box->vname, mail->uid, rec->ref_index);
+ ctx->failed = TRUE;
+ ctx->corrupted = TRUE;
return -1;
}
*msgid_r = msgid;
/* either a match or a collision, need to look closer */
T_BEGIN {
- ret = mail_strmap_rec_get_msgid(ctx->tmp_mail, rec, &msgid);
+ ret = mail_strmap_rec_get_msgid(ctx, rec, &msgid);
if (ret <= 0) {
if (ret < 0)
ctx->failed = TRUE;
int ret;
T_BEGIN {
- ret = mail_strmap_rec_get_msgid(ctx->tmp_mail, rec1, &msgid1);
+ ret = mail_strmap_rec_get_msgid(ctx, rec1, &msgid1);
if (ret > 0) {
msgid1 = t_strdup(msgid1);
- ret = mail_strmap_rec_get_msgid(ctx->tmp_mail, rec2,
- &msgid2);
+ ret = mail_strmap_rec_get_msgid(ctx, rec2, &msgid2);
}
ret = ret <= 0 ? -1 :
strcmp(msgid1, msgid2) == 0;
mail_thread_cache_sync_add(tbox, ctx, search_ctx);
if (mailbox_search_deinit(&search_ctx) < 0)
ret = -1;
-
+ if (ctx->failed) {
+ ret = -1;
+ if (ctx->corrupted)
+ mail_index_strmap_view_set_corrupted(tbox->strmap_view);
+ }
if (ret < 0) {
mail_thread_deinit(&ctx);
return -1;