--- imap/reconstruct.c-BAK 2007-09-10 16:46:12.000000000 +0100 +++ imap/reconstruct.c 2007-09-10 16:50:51.000000000 +0100 @@ -133,6 +133,8 @@ int code = 0; int keepflag = 0; int syncflag = 0; +int uuid_clear = 0; +int uuid_set = 0; int main(int argc, char **argv) { @@ -158,7 +160,7 @@ assert(INDEX_HEADER_SIZE == (OFFSET_SPARE4+4)); assert(INDEX_RECORD_SIZE == (OFFSET_MODSEQ+4)); - while ((opt = getopt(argc, argv, "C:kp:rmfsx")) != EOF) { + while ((opt = getopt(argc, argv, "C:kp:rmfsxuU")) != EOF) { switch (opt) { case 'C': /* alt config file */ alt_config = optarg; @@ -192,6 +194,14 @@ xflag = 1; break; + case 'u': + uuid_clear = 1; + break; + + case 'U': + uuid_set = 1; + break; + default: usage(); } @@ -992,8 +1002,11 @@ if (message_index.modseq > mailbox.highestmodseq) { mailbox.highestmodseq = message_index.modseq; } - - } + } + + /* Force rebuild from message_create_record() */ + if (uuid_set) message_uuid_set_null(&message_index.uuid); + /* NB: message_create_record() will reconstruct SHA1 UUID if NULL */ if (((r = message_parse_file(msgfile, NULL, NULL, &body)) != 0) || ((r = message_create_record(&mailbox, &message_index, body)) != 0)) { @@ -1009,6 +1022,9 @@ fclose(msgfile); if (body) message_free_body(body); + /* Clear out existing or regenerated UUID */ + if (uuid_clear) message_uuid_set_null(&message_index.uuid); + if (expunge_found == 0) { /* Write out new entry in index file */ mailbox_index_record_to_buf(&message_index, buf);