]> git.notmuchmail.org Git - notmuch/blob - test/corpus/cur/10:2,
test: Move corpus emails into maildir directory structure
[notmuch] / test / corpus / cur / 10:2,
1 From: "Mikhail Gusarov" <dottedmag@dottedmag.net>
2 To: notmuch@notmuchmail.org
3 Date: Wed, 18 Nov 2009 02:51:18 +0600
4 Subject: [notmuch] [PATCH] Handle rename of message file
5 Message-ID: <1258491078-29658-1-git-send-email-dottedmag@dottedmag.net>
6
7 If message file has been renamed, just update filename in the DB.
8
9 Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
10 ---
11  lib/database.cc |   21 ++++++++++++---------
12  1 files changed, 12 insertions(+), 9 deletions(-)
13
14 diff --git a/lib/database.cc b/lib/database.cc
15 index 3c8d626..c4eb8b6 100644
16 --- a/lib/database.cc
17 +++ b/lib/database.cc
18 @@ -925,20 +925,23 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
19         if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {
20             _notmuch_message_set_filename (message, filename);
21             _notmuch_message_add_term (message, "type", "mail");
22 +
23 +           ret = _notmuch_database_link_message (notmuch, message, message_file);
24 +           if (ret)
25 +               goto DONE;
26 +
27 +           date = notmuch_message_file_get_header (message_file, "date");
28 +           _notmuch_message_set_date (message, date);
29 +
30 +           _notmuch_message_index_file (message, filename);
31 +       } else if (strcmp(notmuch_message_get_filename(message), filename)) {
32 +           /* Message file has been moved/renamed */
33 +           _notmuch_message_set_filename (message, filename);
34         } else {
35             ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
36             goto DONE;
37         }
38  
39 -       ret = _notmuch_database_link_message (notmuch, message, message_file);
40 -       if (ret)
41 -           goto DONE;
42 -
43 -       date = notmuch_message_file_get_header (message_file, "date");
44 -       _notmuch_message_set_date (message, date);
45 -
46 -       _notmuch_message_index_file (message, filename);
47 -
48         _notmuch_message_sync (message);
49      } catch (const Xapian::Error &error) {
50         fprintf (stderr, "A Xapian exception occurred: %s.\n",
51 -- 
52 1.6.3.3
53
54