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 15C23431FC7
\r
6 for <notmuch@notmuchmail.org>; Sat, 26 Jul 2014 20:54:02 -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 4hE6-G5nrxNH for <notmuch@notmuchmail.org>;
\r
16 Sat, 26 Jul 2014 20:53:56 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.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 80D20431FDB
\r
22 for <notmuch@notmuchmail.org>; Sat, 26 Jul 2014 20:53:15 -0700 (PDT)
\r
23 X-AuditID: 1209190d-f79c06d000002f07-b7-53d477a99c88
\r
24 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\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-2.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id D6.E8.12039.9A774D35; Sat, 26 Jul 2014 23:53:13 -0400 (EDT)
\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
30 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s6R3r2gT014364;
\r
31 Sat, 26 Jul 2014 23:53:02 -0400
\r
32 Received: from drake.dyndns.org
\r
33 (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
34 [216.15.114.40]) (authenticated bits=0)
\r
35 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
36 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s6R3r0UG016404
\r
37 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
38 Sat, 26 Jul 2014 23:53:01 -0400
\r
39 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
40 (envelope-from <amdragon@mit.edu>)
\r
41 id 1XBFW8-00051T-DJ; Sat, 26 Jul 2014 23:53:00 -0400
\r
42 From: Austin Clements <amdragon@MIT.EDU>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH 09/14] lib: Use database features to drive upgrade
\r
45 Date: Sat, 26 Jul 2014 23:52:48 -0400
\r
46 Message-Id: <1406433173-19169-10-git-send-email-amdragon@mit.edu>
\r
47 X-Mailer: git-send-email 2.0.0
\r
48 In-Reply-To: <1406433173-19169-1-git-send-email-amdragon@mit.edu>
\r
49 References: <1406433173-19169-1-git-send-email-amdragon@mit.edu>
\r
50 X-Brightmail-Tracker:
\r
51 H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsUixG6noruy/EqwwbwnGhbXb85kdmD0eLbq
\r
52 FnMAYxSXTUpqTmZZapG+XQJXxpkjTawFS6QqLm+ew9TA2CLaxcjBISFgIrF8X1EXIyeQKSZx
\r
53 4d56ti5GLg4hgdlMEq1velkhnI2MEpuONbBDOHeYJC41drOAtAgJzGWU2L/PEcRmE9CQ2LZ/
\r
54 OSOILSIgLbHz7mxWkA3MAmoSf7pUQMLCAk4Smz++YAexWQRUJbY9u84MYvMKOEpMXXGADeIK
\r
55 OYmGG5/AbE6g+PFnJ9hAxggJOEjcupQ4gZF/ASPDKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl0j
\r
56 vdzMEr3UlNJNjKCA4ZTk3cH47qDSIUYBDkYlHt4MtivBQqyJZcWVuYcYJTmYlER595sBhfiS
\r
57 8lMqMxKLM+KLSnNSiw8xSnAwK4nwChUD5XhTEiurUovyYVLSHCxK4rxvra2ChQTSE0tSs1NT
\r
58 C1KLYLIyHBxKErzTy4AaBYtS01Mr0jJzShDSTBycIMN5gIZvKAUZXlyQmFucmQ6RP8WoKCXO
\r
59 +wskIQCSyCjNg+uFRfQrRnGgV4R5WUFW8ACTAVz3K6DBTECDWfwvgwwuSURISTUwLv7K28pq
\r
60 0hJWszC9y2RtTsSaq3zz4vMlUk99mB3C0h0fd/7e2/tOH6ZLRc3t5y/11H9vpqAtuvLppsmz
\r
61 L6mEabItc9sZqL7zg63FZvusC5fWXjDbaPXxXplThYt/DPvpwwsvStTzJT/QSCjs3TajSsOl
\r
62 0vhm65dPrx8rP4i165+tKDdJMMxaiaU4I9FQi7moOBEA2Yubi8MCAAA=
\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: Sun, 27 Jul 2014 03:54:02 -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 0be7180..1dd2cd9 100644
\r
86 --- a/lib/database.cc
\r
87 +++ b/lib/database.cc
\r
88 @@ -1201,11 +1201,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 + unsigned int target_features, new_features;
\r
99 notmuch_status_t status;
\r
100 unsigned int count = 0, total = 0;
\r
102 @@ -1215,9 +1216,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 @@ -1245,12 +1247,11 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
116 * data field. Copy that into the new format by calling
\r
117 * notmuch_message_add_filename.
\r
119 - if (version < 1) {
\r
120 + if (new_features & NOTMUCH_FEATURE_FILE_TERMS) {
\r
121 notmuch_query_t *query = notmuch_query_create (notmuch, "");
\r
122 notmuch_messages_t *messages;
\r
123 notmuch_message_t *message;
\r
125 - Xapian::TermIterator t, t_end;
\r
127 total = notmuch_query_count_messages (query);
\r
129 @@ -1279,11 +1280,12 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
132 notmuch_query_destroy (query);
\r
135 - /* Also, before version 1 we stored directory timestamps in
\r
136 - * XTIMESTAMP documents instead of the current XDIRECTORY
\r
137 - * documents. So copy those as well. */
\r
139 + /* Also, before version 1 we stored directory timestamps in
\r
140 + * XTIMESTAMP documents instead of the current XDIRECTORY
\r
141 + * documents. So copy those as well. */
\r
142 + if (new_features & NOTMUCH_FEATURE_DIRECTORY_DOCS) {
\r
143 t_end = notmuch->xapian_db->allterms_end ("XTIMESTAMP");
\r
145 for (t = notmuch->xapian_db->allterms_begin ("XTIMESTAMP");
\r
146 @@ -1327,7 +1329,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
147 * stemmed. Change it to the current boolean prefix. Add "path:"
\r
148 * prefixes while at it.
\r
150 - if (version < 2) {
\r
151 + if (new_features & NOTMUCH_FEATURE_BOOL_FOLDER) {
\r
152 notmuch_query_t *query = notmuch_query_create (notmuch, "");
\r
153 notmuch_messages_t *messages;
\r
154 notmuch_message_t *message;
\r
155 @@ -1356,7 +1358,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
156 notmuch_query_destroy (query);
\r
159 - notmuch->features |= NOTMUCH_FEATURES_CURRENT;
\r
160 + notmuch->features = target_features;
\r
161 db->set_metadata ("features", _print_features (local, notmuch->features));
\r
162 db->set_metadata ("version", STRINGIFY (NOTMUCH_DATABASE_VERSION));
\r