From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 4201D6DE0115 for ; Fri, 21 Jul 2017 03:59:07 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=5 tests=[AWL=0.010, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XlVic76Xittd for ; Fri, 21 Jul 2017 03:59:06 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 555236DE012F for ; Fri, 21 Jul 2017 03:58:56 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1dYVao-0002z2-Ru; Fri, 21 Jul 2017 06:55:34 -0400 Received: (nullmailer pid 4908 invoked by uid 1000); Fri, 21 Jul 2017 10:58:47 -0000 From: David Bremner To: notmuch@notmuchmail.org, notmuch@freelists.org Subject: [Patch v4 06/12] lib: index message files with duplicate message-ids Date: Fri, 21 Jul 2017 07:58:34 -0300 Message-Id: <20170721105840.4737-7-david@tethera.net> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170721105840.4737-1-david@tethera.net> References: <20170721105840.4737-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jul 2017 10:59:07 -0000 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. --- lib/add-message.cc | 19 +++++++++++-------- test/T160-json.sh | 4 ++-- test/T670-duplicate-mid.sh | 9 +++++++-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/add-message.cc b/lib/add-message.cc index 2922eaa9..f0a80c4f 100644 --- a/lib/add-message.cc +++ b/lib/add-message.cc @@ -529,19 +529,22 @@ notmuch_database_add_message (notmuch_database_t *notmuch, if (is_ghost) /* Convert ghost message to a regular message */ _notmuch_message_remove_term (message, "type", "ghost"); - ret = _notmuch_database_link_message (notmuch, message, + } + + ret = _notmuch_database_link_message (notmuch, message, message_file, is_ghost); - if (ret) - goto DONE; + if (ret) + goto DONE; + if (is_new || is_ghost) _notmuch_message_set_header_values (message, date, from, subject); - ret = _notmuch_message_index_file (message, message_file); - if (ret) - goto DONE; - } else { + ret = _notmuch_message_index_file (message, message_file); + if (ret) + goto DONE; + + if (! is_new && !is_ghost) ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID; - } _notmuch_message_sync (message); } catch (const Xapian::Error &error) { diff --git a/test/T160-json.sh b/test/T160-json.sh index ac51895e..07955a2b 100755 --- a/test/T160-json.sh +++ b/test/T160-json.sh @@ -71,8 +71,8 @@ test_begin_subtest "Format version: too high" test_expect_code 21 "notmuch search --format-version=999 \\*" test_begin_subtest "Show message: multiple filenames" -add_message "[id]=message-id@example.com [filename]=copy1" -add_message "[id]=message-id@example.com [filename]=copy2" +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 [date]="Fri, 05 Jan 2001 15:43:52 +0000"' cat < EXPECTED [ [ diff --git a/test/T670-duplicate-mid.sh b/test/T670-duplicate-mid.sh index ced28a21..137cb6a5 100755 --- a/test/T670-duplicate-mid.sh +++ b/test/T670-duplicate-mid.sh @@ -5,8 +5,14 @@ test_description="duplicate message ids" add_message '[id]="duplicate"' '[subject]="message 1" [filename]=copy1' add_message '[id]="duplicate"' '[subject]="message 2" [filename]=copy2' +test_begin_subtest 'First subject preserved' +cat < 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_subtest_known_broken cat <EXPECTED MAIL_DIR/copy1 MAIL_DIR/copy2 @@ -16,7 +22,6 @@ test_expect_equal_file EXPECTED OUTPUT add_message '[id]="duplicate"' '[body]="sekrit" [filename]=copy3' test_begin_subtest 'search for body in duplicate file' -test_subtest_known_broken cat <EXPECTED MAIL_DIR/copy1 MAIL_DIR/copy2 -- 2.13.2