1 Return-Path: <dottedmag@dottedmag.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id DE52D431FBC
\r
6 for <notmuch@notmuchmail.org>; Tue, 17 Nov 2009 12:51:20 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id vSNyQAFba5ed for <notmuch@notmuchmail.org>;
\r
11 Tue, 17 Nov 2009 12:51:20 -0800 (PST)
\r
12 Received: from dottedmag.net (burger.dottedmag.net [212.75.37.82])
\r
13 by olra.theworths.org (Postfix) with ESMTP id 40D02431FAE
\r
14 for <notmuch@notmuchmail.org>; Tue, 17 Nov 2009 12:51:20 -0800 (PST)
\r
15 Received: from vertex.dottedmag (unknown [91.197.127.125])
\r
16 by dottedmag.net (Postfix) with ESMTPSA id 923208C03E
\r
17 for <notmuch@notmuchmail.org>; Tue, 17 Nov 2009 21:51:19 +0100 (CET)
\r
18 Received: from dottedmag by vertex.dottedmag with local (Exim 4.69)
\r
19 (envelope-from <dottedmag@dottedmag.net>) id 1NAV1C-0007is-8Z
\r
20 for notmuch@notmuchmail.org; Wed, 18 Nov 2009 02:51:18 +0600
\r
21 From: Mikhail Gusarov <dottedmag@dottedmag.net>
\r
22 To: notmuch@notmuchmail.org
\r
23 Date: Wed, 18 Nov 2009 02:51:18 +0600
\r
24 Message-Id: <1258491078-29658-1-git-send-email-dottedmag@dottedmag.net>
\r
25 X-Mailer: git-send-email 1.6.3.3
\r
26 Subject: [notmuch] [PATCH] Handle rename of message file
\r
27 X-BeenThere: notmuch@notmuchmail.org
\r
28 X-Mailman-Version: 2.1.12
\r
30 List-Id: "Use and development of the notmuch mail system."
\r
31 <notmuch.notmuchmail.org>
\r
32 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
33 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
34 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
35 List-Post: <mailto:notmuch@notmuchmail.org>
\r
36 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
37 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
38 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
39 X-List-Received-Date: Tue, 17 Nov 2009 20:51:21 -0000
\r
41 If message file has been renamed, just update filename in the DB.
\r
43 Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
\r
45 lib/database.cc | 21 ++++++++++++---------
\r
46 1 files changed, 12 insertions(+), 9 deletions(-)
\r
48 diff --git a/lib/database.cc b/lib/database.cc
\r
49 index 3c8d626..c4eb8b6 100644
\r
50 --- a/lib/database.cc
\r
51 +++ b/lib/database.cc
\r
52 @@ -925,20 +925,23 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
53 if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {
\r
54 _notmuch_message_set_filename (message, filename);
\r
55 _notmuch_message_add_term (message, "type", "mail");
\r
57 + ret = _notmuch_database_link_message (notmuch, message, message_file);
\r
61 + date = notmuch_message_file_get_header (message_file, "date");
\r
62 + _notmuch_message_set_date (message, date);
\r
64 + _notmuch_message_index_file (message, filename);
\r
65 + } else if (strcmp(notmuch_message_get_filename(message), filename)) {
\r
66 + /* Message file has been moved/renamed */
\r
67 + _notmuch_message_set_filename (message, filename);
\r
69 ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
\r
73 - ret = _notmuch_database_link_message (notmuch, message, message_file);
\r
77 - date = notmuch_message_file_get_header (message_file, "date");
\r
78 - _notmuch_message_set_date (message, date);
\r
80 - _notmuch_message_index_file (message, filename);
\r
82 _notmuch_message_sync (message);
\r
83 } catch (const Xapian::Error &error) {
\r
84 fprintf (stderr, "A Xapian exception occurred: %s.\n",
\r