Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 99 / be9733e86f841169314a9aa58a86a8d71177ef
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 0FADA431FC7\r
6         for <notmuch@notmuchmail.org>; Thu,  3 Apr 2014 19:44:41 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id nhOasN8K3G97 for <notmuch@notmuchmail.org>;\r
16         Thu,  3 Apr 2014 19:44:37 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18         [87.98.215.224]) (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id B0128431FBF\r
21         for <notmuch@notmuchmail.org>; Thu,  3 Apr 2014 19:44:32 -0700 (PDT)\r
22 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
23         4.72) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
24         id 1WVtXU-00017G-Nl; Fri, 04 Apr 2014 02:07:28 +0000\r
25 Received: (nullmailer pid 4020 invoked by uid 1000); Thu, 03 Apr 2014\r
26         19:41:39 -0000\r
27 From: David Bremner <david@tethera.net>\r
28 To: notmuch@notmuchmail.org\r
29 Subject: [Patch v6 5/6] notmuch-new: backup tags before database upgrade\r
30 Date: Thu,  3 Apr 2014 16:41:22 -0300\r
31 Message-Id: <1396554083-3892-6-git-send-email-david@tethera.net>\r
32 X-Mailer: git-send-email 1.9.0\r
33 In-Reply-To: <1396554083-3892-1-git-send-email-david@tethera.net>\r
34 References: <1396554083-3892-1-git-send-email-david@tethera.net>\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.13\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39         <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Fri, 04 Apr 2014 02:44:41 -0000\r
48 \r
49 All we do here is calculate the backup filename, and call the existing\r
50 dump routine.\r
51 \r
52 Also take the opportity to add a message about being safe to\r
53 interrupt.\r
54 ---\r
55  notmuch-new.c        | 29 ++++++++++++++++++++++++++++-\r
56  test/T530-upgrade.sh |  4 +++-\r
57  2 files changed, 31 insertions(+), 2 deletions(-)\r
58 \r
59 diff --git a/notmuch-new.c b/notmuch-new.c\r
60 index 82acf69..d269c7c 100644\r
61 --- a/notmuch-new.c\r
62 +++ b/notmuch-new.c\r
63 @@ -989,8 +989,35 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
64             return EXIT_FAILURE;\r
65  \r
66         if (notmuch_database_needs_upgrade (notmuch)) {\r
67 -           if (add_files_state.verbosity >= VERBOSITY_NORMAL)\r
68 +           time_t now = time (NULL);\r
69 +           struct tm *gm_time = gmtime (&now);\r
70 +\r
71 +           /* since dump files are written atomically, the amount of\r
72 +            * harm from overwriting one within a second seems\r
73 +            * relatively small. */\r
74 +\r
75 +           const char *backup_name =\r
76 +               talloc_asprintf (notmuch, "%s/dump-%04d%02d%02dT%02d%02d%02d.gz",\r
77 +                                dot_notmuch_path,\r
78 +                                gm_time->tm_year + 1900,\r
79 +                                gm_time->tm_mon + 1,\r
80 +                                gm_time->tm_mday,\r
81 +                                gm_time->tm_hour,\r
82 +                                gm_time->tm_min,\r
83 +                                gm_time->tm_sec);\r
84 +\r
85 +           if (add_files_state.verbosity >= VERBOSITY_NORMAL) {\r
86                 printf ("Welcome to a new version of notmuch! Your database will now be upgraded.\n");\r
87 +               printf ("This process is safe to interrupt.\n");\r
88 +               printf ("Backing up tags to %s...\n", backup_name);\r
89 +           }\r
90 +\r
91 +           if (notmuch_database_dump (notmuch, backup_name, "",\r
92 +                                      DUMP_FORMAT_BATCH_TAG, TRUE)) {\r
93 +               fprintf (stderr, "Backup failed. Aborting upgrade.");\r
94 +               return EXIT_FAILURE;\r
95 +           }\r
96 +\r
97             gettimeofday (&add_files_state.tv_start, NULL);\r
98             notmuch_database_upgrade (notmuch,\r
99                                       add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,\r
100 diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh\r
101 index 67bbf31..d46e3d1 100755\r
102 --- a/test/T530-upgrade.sh\r
103 +++ b/test/T530-upgrade.sh\r
104 @@ -26,9 +26,11 @@ output=$(notmuch search path:foo)\r
105  test_expect_equal "$output" ""\r
106  \r
107  test_begin_subtest "database upgrade from format version 1"\r
108 -output=$(notmuch new)\r
109 +output=$(notmuch new | sed -e 's/^Backing up tags to .*$/Backing up tags to FILENAME/')\r
110  test_expect_equal "$output" "\\r
111  Welcome to a new version of notmuch! Your database will now be upgraded.\r
112 +This process is safe to interrupt.\r
113 +Backing up tags to FILENAME\r
114  Your notmuch database has now been upgraded to database format version 2.\r
115  No new mail."\r
116  \r
117 -- \r
118 1.9.0\r
119 \r