value = t_strdup_until(file->fname, p);
}
break;
+ case DBOX_METADATA_ORIG_MAILBOX:
case DBOX_METADATA_OLDV1_EXPUNGED:
case DBOX_METADATA_OLDV1_FLAGS:
case DBOX_METADATA_OLDV1_KEYWORDS:
/* Pointer to external message data. Format is:
1*(<start offset> <byte count> <ref>) */
DBOX_METADATA_EXT_REF = 'X',
+ /* Mailbox name where this message was originally saved to.
+ When rebuild finds a message whose mailbox is unknown, it's
+ placed to this mailbox. */
+ DBOX_METADATA_ORIG_MAILBOX = 'B',
/* metadata used by old Dovecot versions */
DBOX_METADATA_OLDV1_EXPUNGED = 'E',
guid_128, NULL);
}
str_printfa(str, "%c%s\n", DBOX_METADATA_GUID, guid);
+ if (ctx->cur_file->single_mbox == NULL &&
+ strchr(ctx->mbox->ibox.box.name, '\r') == NULL &&
+ strchr(ctx->mbox->ibox.box.name, '\n') == NULL) {
+ /* multi-file: save the original mailbox name so if mailbox
+ indexes get corrupted we can place at least some
+ (hopefully most) of the messages to correct mailboxes. */
+ str_printfa(str, "%c%s\n", DBOX_METADATA_ORIG_MAILBOX,
+ ctx->mbox->ibox.box.name);
+ }
str_append_c(str, '\n');
o_stream_send(ctx->cur_output, str_data(str), str_len(str));