Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / c0 / 0fec2fa5e5bca53fd4f50725e45821f8d99a76
1 Return-Path: <jani@nikula.org>\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 200A8431FCB\r
6         for <notmuch@notmuchmail.org>; Sun,  3 Nov 2013 04:25:43 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id PLP5jADX9ZJm for <notmuch@notmuchmail.org>;\r
17         Sun,  3 Nov 2013 04:25:37 -0800 (PST)\r
18 Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com\r
19  [74.125.83.49])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
20  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
21  8E2D9429E25    for <notmuch@notmuchmail.org>; Sun,  3 Nov 2013 04:25:13 -0800\r
22  (PST)\r
23 Received: by mail-ee0-f49.google.com with SMTP id e52so580835eek.36\r
24         for <notmuch@notmuchmail.org>; Sun, 03 Nov 2013 04:25:12 -0800 (PST)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=1e100.net; s=20130820;\r
27         h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
28         :references:in-reply-to:references;\r
29         bh=hsWsMcdXmJOySzux5u60RChOOl+XhERARCk5b5+VOzU=;\r
30         b=MAUAhEpwbW3QzY6XQV+1iYZHiOUt5gNx8gOJniDhqVW4OINgokuKcFRVD9Hp/C8jot\r
31         PGFITn73nNUvlxzI0EUBNZm95FHwDmwfDU3rY+vqqmqI9zeUBp18qw7qo+sYd3FbKjrq\r
32         GF5+vU1nEb6Rnois3vJe6lpKcB6rDV8byg15CShLcCF3zmt7IvpBCMVmV4qqMEZ5L6VY\r
33         W9JQ4IRNcOr1vP5+VEbl79NjDfib2+jG9jhpXn2wfxftD2IafdK9Ur2j7RGyIWZ/O+jt\r
34         DdwwxsJU9RiO6ycBdKfAc19/LJFBs/Un2qkf8t5RtB+lCmFOv5pgzwb5szxooq1SReEi\r
35         tfKw==\r
36 X-Gm-Message-State:\r
37  ALoCoQnphsxQPLcyzjyYZ0eDQuWtuLLM4OqkKRHGv13zuNELDTUe7BLoFJ+ZT4DYpzMjbSSqNl7o\r
38 X-Received: by 10.15.10.6 with SMTP id f6mr1614135eet.57.1383481512392;\r
39         Sun, 03 Nov 2013 04:25:12 -0800 (PST)\r
40 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
41         [88.195.111.91]) by mx.google.com with ESMTPSA id\r
42         u46sm32772104eep.17.2013.11.03.04.25.10 for <multiple recipients>\r
43         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
44         Sun, 03 Nov 2013 04:25:11 -0800 (PST)\r
45 From: Jani Nikula <jani@nikula.org>\r
46 To: notmuch@notmuchmail.org\r
47 Subject: [PATCH v2 07/11] lib: use the compaction backup path provided by the\r
48         caller\r
49 Date: Sun,  3 Nov 2013 14:24:47 +0200\r
50 Message-Id:\r
51  <6e8053834c8ab856c2ebab881069f18b2badcf71.1383481295.git.jani@nikula.org>\r
52 X-Mailer: git-send-email 1.8.4.rc3\r
53 In-Reply-To: <cover.1383481295.git.jani@nikula.org>\r
54 References: <cover.1383481295.git.jani@nikula.org>\r
55 In-Reply-To: <cover.1383481295.git.jani@nikula.org>\r
56 References: <cover.1383481295.git.jani@nikula.org>\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\r
60 List-Id: "Use and development of the notmuch mail system."\r
61         <notmuch.notmuchmail.org>\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
65 List-Post: <mailto:notmuch@notmuchmail.org>\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
69 X-List-Received-Date: Sun, 03 Nov 2013 12:25:43 -0000\r
70 \r
71 The extra path component added by the lib is a magic value that the\r
72 caller just has to know. This is demonstrated by the current code,\r
73 which indeed has "xapian.old" both sides of the interface. Use the\r
74 backup path provided by the lib caller verbatim, without adding\r
75 anything to it.\r
76 \r
77 ---\r
78 \r
79 v2: add xapian.old in cli\r
80 ---\r
81  lib/database.cc   | 14 ++++----------\r
82  notmuch-compact.c | 10 +++++++---\r
83  2 files changed, 11 insertions(+), 13 deletions(-)\r
84 \r
85 diff --git a/lib/database.cc b/lib/database.cc\r
86 index 5a01703..a021bf1 100644\r
87 --- a/lib/database.cc\r
88 +++ b/lib/database.cc\r
89 @@ -868,7 +868,6 @@ notmuch_database_compact (const char* path,\r
90  {\r
91      void *local;\r
92      char *notmuch_path, *xapian_path, *compact_xapian_path;\r
93 -    char *old_xapian_path = NULL;\r
94      notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;\r
95      notmuch_database_t *notmuch = NULL;\r
96      struct stat statbuf;\r
97 @@ -898,13 +897,8 @@ notmuch_database_compact (const char* path,\r
98      }\r
99  \r
100      if (backup_path != NULL) {\r
101 -       if (! (old_xapian_path = talloc_asprintf (local, "%s/xapian.old", backup_path))) {\r
102 -           ret = NOTMUCH_STATUS_OUT_OF_MEMORY;\r
103 -           goto DONE;\r
104 -       }\r
105 -\r
106 -       if (stat(old_xapian_path, &statbuf) != -1) {\r
107 -           fprintf (stderr, "Backup path already exists: %s\n", old_xapian_path);\r
108 +       if (stat(backup_path, &statbuf) != -1) {\r
109 +           fprintf (stderr, "Backup path already exists: %s\n", backup_path);\r
110             ret = NOTMUCH_STATUS_FILE_ERROR;\r
111             goto DONE;\r
112         }\r
113 @@ -928,8 +922,8 @@ notmuch_database_compact (const char* path,\r
114         goto DONE;\r
115      }\r
116  \r
117 -    if (old_xapian_path != NULL) {\r
118 -       if (rename(xapian_path, old_xapian_path)) {\r
119 +    if (backup_path) {\r
120 +       if (rename(xapian_path, backup_path)) {\r
121             fprintf (stderr, "Error moving old database out of the way\n");\r
122             ret = NOTMUCH_STATUS_FILE_ERROR;\r
123             goto DONE;\r
124 diff --git a/notmuch-compact.c b/notmuch-compact.c\r
125 index ee7afcf..55dc731 100644\r
126 --- a/notmuch-compact.c\r
127 +++ b/notmuch-compact.c\r
128 @@ -32,9 +32,13 @@ notmuch_compact_command (notmuch_config_t *config,\r
129                          unused (char *argv[]))\r
130  {\r
131      const char *path = notmuch_config_get_database_path (config);\r
132 -    const char *backup_path = path;\r
133 +    const char *backup_path;\r
134      notmuch_status_t ret;\r
135  \r
136 +    backup_path = talloc_asprintf (config, "%s/xapian.old", path);\r
137 +    if (! backup_path)\r
138 +       return 1;\r
139 +\r
140      printf ("Compacting database...\n");\r
141      ret = notmuch_database_compact (path, backup_path, status_update_cb, NULL);\r
142      if (ret) {\r
143 @@ -42,11 +46,11 @@ notmuch_compact_command (notmuch_config_t *config,\r
144      } else {\r
145         printf ("\n");\r
146         printf ("\n");\r
147 -       printf ("The old database has been moved to %s/xapian.old", backup_path);\r
148 +       printf ("The old database has been moved to %s", backup_path);\r
149         printf ("\n");\r
150         printf ("To delete run,\n");\r
151         printf ("\n");\r
152 -       printf ("    rm -R %s/xapian.old\n", backup_path);\r
153 +       printf ("    rm -R %s\n", backup_path);\r
154         printf ("\n");\r
155      }\r
156  \r
157 -- \r
158 1.8.4.rc3\r
159 \r