1 Return-Path: <amdragon@mit.edu>
\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 0EC13431FBC
\r
6 for <notmuch@notmuchmail.org>; Mon, 25 Aug 2014 10:26:35 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_MED=-2.3] 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 XhRM-ylbaTX7 for <notmuch@notmuchmail.org>;
\r
16 Mon, 25 Aug 2014 10:26:29 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-1.mit.edu (dmz-mailsec-scanner-1.mit.edu
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 84990431FBD
\r
22 for <notmuch@notmuchmail.org>; Mon, 25 Aug 2014 10:26:19 -0700 (PDT)
\r
23 X-AuditID: 1209190c-f795e6d000006c66-af-53fb71b9585b
\r
24 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
25 (using TLS with cipher AES256-SHA (256/256 bits))
\r
26 (Client did not present a certificate)
\r
27 by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id 8F.F6.27750.9B17BF35; Mon, 25 Aug 2014 13:26:17 -0400 (EDT)
\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
30 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s7PHQE4v007793;
\r
31 Mon, 25 Aug 2014 13:26:14 -0400
\r
32 Received: from drake.dyndns.org (31-35-14.wireless.csail.mit.edu
\r
33 [128.31.35.14]) (authenticated bits=0)
\r
34 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
35 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s7PHQCBA029615
\r
36 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
37 Mon, 25 Aug 2014 13:26:13 -0400
\r
38 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
39 (envelope-from <amdragon@mit.edu>)
\r
40 id 1XLy20-0003jY-0d; Mon, 25 Aug 2014 13:26:12 -0400
\r
41 From: Austin Clements <amdragon@mit.edu>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH v4 06/11] lib: Use database features to drive upgrade
\r
44 Date: Mon, 25 Aug 2014 13:26:04 -0400
\r
45 Message-Id: <1408987569-14146-7-git-send-email-amdragon@mit.edu>
\r
46 X-Mailer: git-send-email 2.0.0
\r
47 In-Reply-To: <1408987569-14146-1-git-send-email-amdragon@mit.edu>
\r
48 References: <1408987569-14146-1-git-send-email-amdragon@mit.edu>
\r
49 X-Brightmail-Tracker:
\r
50 H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixCmqrLuz8HewwfsnGhY3WrsZLZqmO1tc
\r
51 vzmT2YHZ49b91+wez1bdYvbYcug9cwBzFJdNSmpOZllqkb5dAlfGmb1bWQoOSFb8uLaPsYFx
\r
52 lkgXIyeHhICJxMbmhywQtpjEhXvr2boYuTiEBGYzSax5sJcVwtnIKHHnVBszSJWQwDEmiftN
\r
53 ZhCJuYwSi+49ZAdJsAloSPy+tZgJxBYRkJbYeXc2K4jNLOAlsexCP5gtLOAq8al/O1gNi4Cq
\r
54 xJULO4F6OTh4BRwkJhwzh7hCTqLhxic2EJtTwFFi+sLZTBB7HSS+Xz7PPIGRfwEjwypG2ZTc
\r
55 Kt3cxMyc4tRk3eLkxLy81CJdQ73czBK91JTSTYzg0JLk2cH45qDSIUYBDkYlHt4b8b+DhVgT
\r
56 y4orcw8xSnIwKYnyTssHCvEl5adUZiQWZ8QXleakFh9ilOBgVhLhbQbJ8aYkVlalFuXDpKQ5
\r
57 WJTEed9aWwULCaQnlqRmp6YWpBbBZGU4OJQkeHMLgBoFi1LTUyvSMnNKENJMHJwgw3mAhseD
\r
58 1PAWFyTmFmemQ+RPMSpKifOuBdkqAJLIKM2D64XF/itGcaBXhHmPgrTzANMGXPcroMFMQINN
\r
59 e36CDC5JREhJNTCq3Lt3fcXef7f0qy1OhR38+aeM16WQkXuW61TWigUsD+/4X7uvffulkqjD
\r
60 GtHsolVO3hslZW9ze/ecWdr6pb0nkynyajCf2NW8cvnje9L+Cr4p2GBcvPfQjzMLGLb4nc1T
\r
61 VZzQeWvjeiXjuXs2yqQ8LHvlduT+rEtHr14ozXfRbvNVF/u9rjxMiaU4I9FQi7moOBEAvrCj
\r
63 X-BeenThere: notmuch@notmuchmail.org
\r
64 X-Mailman-Version: 2.1.13
\r
66 List-Id: "Use and development of the notmuch mail system."
\r
67 <notmuch.notmuchmail.org>
\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
71 List-Post: <mailto:notmuch@notmuchmail.org>
\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
74 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
75 X-List-Received-Date: Mon, 25 Aug 2014 17:26:35 -0000
\r
77 Previously, we had database version information hard-coded in the
\r
78 upgrade code. Slightly re-organize the upgrade process around the set
\r
79 of new database features to be enabled by the upgrade.
\r
81 lib/database.cc | 24 +++++++++++++-----------
\r
82 1 file changed, 13 insertions(+), 11 deletions(-)
\r
84 diff --git a/lib/database.cc b/lib/database.cc
\r
85 index 1e46fc8..525c9c3 100644
\r
86 --- a/lib/database.cc
\r
87 +++ b/lib/database.cc
\r
88 @@ -1202,11 +1202,12 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
91 void *local = talloc_new (NULL);
\r
92 + Xapian::TermIterator t, t_end;
\r
93 Xapian::WritableDatabase *db;
\r
94 struct sigaction action;
\r
95 struct itimerval timerval;
\r
96 notmuch_bool_t timer_is_active = FALSE;
\r
97 - unsigned int version;
\r
98 + enum _notmuch_features target_features, new_features;
\r
99 notmuch_status_t status;
\r
100 unsigned int count = 0, total = 0;
\r
102 @@ -1216,9 +1217,10 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
104 db = static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db);
\r
106 - version = notmuch_database_get_version (notmuch);
\r
107 + target_features = notmuch->features | NOTMUCH_FEATURES_CURRENT;
\r
108 + new_features = NOTMUCH_FEATURES_CURRENT & ~notmuch->features;
\r
110 - if (version >= NOTMUCH_DATABASE_VERSION)
\r
111 + if (! new_features)
\r
112 return NOTMUCH_STATUS_SUCCESS;
\r
114 if (progress_notify) {
\r
115 @@ -1244,18 +1246,17 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
117 /* Set the target features so we write out changes in the desired
\r
119 - notmuch->features |= NOTMUCH_FEATURES_CURRENT;
\r
120 + notmuch->features = target_features;
\r
122 /* Before version 1, each message document had its filename in the
\r
123 * data field. Copy that into the new format by calling
\r
124 * notmuch_message_add_filename.
\r
126 - if (version < 1) {
\r
127 + if (new_features & NOTMUCH_FEATURE_FILE_TERMS) {
\r
128 notmuch_query_t *query = notmuch_query_create (notmuch, "");
\r
129 notmuch_messages_t *messages;
\r
130 notmuch_message_t *message;
\r
132 - Xapian::TermIterator t, t_end;
\r
134 total = notmuch_query_count_messages (query);
\r
136 @@ -1284,11 +1285,12 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
139 notmuch_query_destroy (query);
\r
142 - /* Also, before version 1 we stored directory timestamps in
\r
143 - * XTIMESTAMP documents instead of the current XDIRECTORY
\r
144 - * documents. So copy those as well. */
\r
146 + /* Also, before version 1 we stored directory timestamps in
\r
147 + * XTIMESTAMP documents instead of the current XDIRECTORY
\r
148 + * documents. So copy those as well. */
\r
149 + if (new_features & NOTMUCH_FEATURE_DIRECTORY_DOCS) {
\r
150 t_end = notmuch->xapian_db->allterms_end ("XTIMESTAMP");
\r
152 for (t = notmuch->xapian_db->allterms_begin ("XTIMESTAMP");
\r
153 @@ -1332,7 +1334,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
154 * stemmed. Change it to the current boolean prefix. Add "path:"
\r
155 * prefixes while at it.
\r
157 - if (version < 2) {
\r
158 + if (new_features & NOTMUCH_FEATURE_BOOL_FOLDER) {
\r
159 notmuch_query_t *query = notmuch_query_create (notmuch, "");
\r
160 notmuch_messages_t *messages;
\r
161 notmuch_message_t *message;
\r