mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
lib: index message files with duplicate message-ids
The corresponding xapian document just gets more terms added to it, but this doesn't seem to break anything. Values on the other hand get overwritten, which is a bit annoying, but arguably it is not worse to take the values (from, subject, date) from the last file indexed rather than the first.
This commit is contained in:
parent
639aced9c9
commit
411675a6ce
3 changed files with 21 additions and 13 deletions
|
@ -529,19 +529,22 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
|
||||||
if (is_ghost)
|
if (is_ghost)
|
||||||
/* Convert ghost message to a regular message */
|
/* Convert ghost message to a regular message */
|
||||||
_notmuch_message_remove_term (message, "type", "ghost");
|
_notmuch_message_remove_term (message, "type", "ghost");
|
||||||
ret = _notmuch_database_link_message (notmuch, message,
|
}
|
||||||
message_file, is_ghost);
|
|
||||||
if (ret)
|
|
||||||
goto DONE;
|
|
||||||
|
|
||||||
|
ret = _notmuch_database_link_message (notmuch, message,
|
||||||
|
message_file, is_ghost);
|
||||||
|
if (ret)
|
||||||
|
goto DONE;
|
||||||
|
|
||||||
|
if (is_new || is_ghost)
|
||||||
_notmuch_message_set_header_values (message, date, from, subject);
|
_notmuch_message_set_header_values (message, date, from, subject);
|
||||||
|
|
||||||
ret = _notmuch_message_index_file (message, message_file);
|
ret = _notmuch_message_index_file (message, message_file);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto DONE;
|
goto DONE;
|
||||||
} else {
|
|
||||||
|
if (! is_new && !is_ghost)
|
||||||
ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
|
ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
|
||||||
}
|
|
||||||
|
|
||||||
_notmuch_message_sync (message);
|
_notmuch_message_sync (message);
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
|
|
|
@ -71,8 +71,8 @@ test_begin_subtest "Format version: too high"
|
||||||
test_expect_code 21 "notmuch search --format-version=999 \\*"
|
test_expect_code 21 "notmuch search --format-version=999 \\*"
|
||||||
|
|
||||||
test_begin_subtest "Show message: multiple filenames"
|
test_begin_subtest "Show message: multiple filenames"
|
||||||
add_message "[id]=message-id@example.com [filename]=copy1"
|
add_message '[id]=message-id@example.com [filename]=copy1 [date]="Fri, 05 Jan 2001 15:43:52 +0000"'
|
||||||
add_message "[id]=message-id@example.com [filename]=copy2"
|
add_message '[id]=message-id@example.com [filename]=copy2 [date]="Fri, 05 Jan 2001 15:43:52 +0000"'
|
||||||
cat <<EOF > EXPECTED
|
cat <<EOF > EXPECTED
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
|
|
|
@ -5,8 +5,14 @@ test_description="duplicate message ids"
|
||||||
add_message '[id]="duplicate"' '[subject]="message 1" [filename]=copy1'
|
add_message '[id]="duplicate"' '[subject]="message 1" [filename]=copy1'
|
||||||
add_message '[id]="duplicate"' '[subject]="message 2" [filename]=copy2'
|
add_message '[id]="duplicate"' '[subject]="message 2" [filename]=copy2'
|
||||||
|
|
||||||
|
test_begin_subtest 'First subject preserved'
|
||||||
|
cat <<EOF > EXPECTED
|
||||||
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; message 1 (inbox unread)
|
||||||
|
EOF
|
||||||
|
notmuch search id:duplicate | notmuch_search_sanitize > OUTPUT
|
||||||
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
test_begin_subtest 'Search for second subject'
|
test_begin_subtest 'Search for second subject'
|
||||||
test_subtest_known_broken
|
|
||||||
cat <<EOF >EXPECTED
|
cat <<EOF >EXPECTED
|
||||||
MAIL_DIR/copy1
|
MAIL_DIR/copy1
|
||||||
MAIL_DIR/copy2
|
MAIL_DIR/copy2
|
||||||
|
@ -16,7 +22,6 @@ test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
add_message '[id]="duplicate"' '[body]="sekrit" [filename]=copy3'
|
add_message '[id]="duplicate"' '[body]="sekrit" [filename]=copy3'
|
||||||
test_begin_subtest 'search for body in duplicate file'
|
test_begin_subtest 'search for body in duplicate file'
|
||||||
test_subtest_known_broken
|
|
||||||
cat <<EOF >EXPECTED
|
cat <<EOF >EXPECTED
|
||||||
MAIL_DIR/copy1
|
MAIL_DIR/copy1
|
||||||
MAIL_DIR/copy2
|
MAIL_DIR/copy2
|
||||||
|
|
Loading…
Reference in a new issue