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 175C3429E31
\r
6 for <notmuch@notmuchmail.org>; Tue, 29 Jul 2014 09:48:45 -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 pqUN-NnF6Yl6 for <notmuch@notmuchmail.org>;
\r
16 Tue, 29 Jul 2014 09:48:39 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.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 83E12431FC7
\r
22 for <notmuch@notmuchmail.org>; Tue, 29 Jul 2014 09:48:21 -0700 (PDT)
\r
23 X-AuditID: 1209190e-f79946d000007db1-c7-53d7d054e2c7
\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-3.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id 69.F5.32177.450D7D35; Tue, 29 Jul 2014 12:48:20 -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 s6TGmIaR003295;
\r
31 Tue, 29 Jul 2014 12:48:18 -0400
\r
32 Received: from drake.dyndns.org (31-33-71.wireless.csail.mit.edu
\r
33 [128.31.33.71]) (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 s6TGmFfJ030264
\r
36 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
37 Tue, 29 Jul 2014 12:48:17 -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 1XCAZS-0007Gz-Ta; Tue, 29 Jul 2014 12:48:14 -0400
\r
41 From: Austin Clements <amdragon@MIT.EDU>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH v2 09/14] lib: Use database features to drive upgrade
\r
44 Date: Tue, 29 Jul 2014 12:48:07 -0400
\r
45 Message-Id: <1406652492-27803-10-git-send-email-amdragon@mit.edu>
\r
46 X-Mailer: git-send-email 2.0.0
\r
47 In-Reply-To: <1406652492-27803-1-git-send-email-amdragon@mit.edu>
\r
48 References: <1406652492-27803-1-git-send-email-amdragon@mit.edu>
\r
49 X-Brightmail-Tracker:
\r
50 H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsUixG6nohty4XqwweZGHYvVc3ksrt+cyezA
\r
51 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZRy4KV2wRKriweL3TA2MLaJdjJwcEgImEt3d
\r
52 k5ghbDGJC/fWs3UxcnEICcxmkrh48QUjhLORUeLS1jVQmWNMEru+N7JCOHMZJa7PvQjWzyag
\r
53 IbFt/3JGEFtEQFpi593ZrCA2s4CjxOf9i9hAbGEBV4nXH14xgdgsAqoS15uPAtkcHLxANRd/
\r
54 80KcISfRcOMTWDknUPjWvbtg5UICDhKHZm1mmcDIv4CRYRWjbEpulW5uYmZOcWqybnFyYl5e
\r
55 apGusV5uZoleakrpJkZQGHFK8u1g/HpQ6RCjAAejEg/vhrnXgoVYE8uKK3MPMUpyMCmJ8urt
\r
56 ux4sxJeUn1KZkVicEV9UmpNafIhRgoNZSYSX7yxQjjclsbIqtSgfJiXNwaIkzvvW2ipYSCA9
\r
57 sSQ1OzW1ILUIJivDwaEkwfv6PFCjYFFqempFWmZOCUKaiYMTZDgP0PB9IDW8xQWJucWZ6RD5
\r
58 U4yKUuK8m0ASAiCJjNI8uF5YnL9iFAd6RZj3IEgVDzBFwHW/AhrMBDSY1QVscEkiQkqqgVH9
\r
59 DBfnIZ9lTjb3b5sm8yVf+Bu3+Udt2v4rK72WS0xIc14VzXMjP/yZYe+qN1msbJdnyvlGNZi4
\r
60 PH7cI2p88WLLhXseLff2lPxrbQiocpBafjb48Crhu6VzJDb+yDBxEwo3Pmh89/6TcOeVFxoO
\r
61 X6/uPivyIK556WLuovVn0555Hdk+u8Tf8KoSS3FGoqEWc1FxIgAAOkvjzgIAAA==
\r
62 X-BeenThere: notmuch@notmuchmail.org
\r
63 X-Mailman-Version: 2.1.13
\r
65 List-Id: "Use and development of the notmuch mail system."
\r
66 <notmuch.notmuchmail.org>
\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
70 List-Post: <mailto:notmuch@notmuchmail.org>
\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
73 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
74 X-List-Received-Date: Tue, 29 Jul 2014 16:48:45 -0000
\r
76 Previously, we had database version information hard-coded in the
\r
77 upgrade code. Slightly re-organize the upgrade process around the set
\r
78 of new database features to be enabled by the upgrade.
\r
80 lib/database.cc | 24 +++++++++++++-----------
\r
81 1 file changed, 13 insertions(+), 11 deletions(-)
\r
83 diff --git a/lib/database.cc b/lib/database.cc
\r
84 index e4a1072..5f68550 100644
\r
85 --- a/lib/database.cc
\r
86 +++ b/lib/database.cc
\r
87 @@ -1195,11 +1195,12 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
90 void *local = talloc_new (NULL);
\r
91 + Xapian::TermIterator t, t_end;
\r
92 Xapian::WritableDatabase *db;
\r
93 struct sigaction action;
\r
94 struct itimerval timerval;
\r
95 notmuch_bool_t timer_is_active = FALSE;
\r
96 - unsigned int version;
\r
97 + unsigned int target_features, new_features;
\r
98 notmuch_status_t status;
\r
99 unsigned int count = 0, total = 0;
\r
101 @@ -1209,9 +1210,10 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
103 db = static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db);
\r
105 - version = notmuch_database_get_version (notmuch);
\r
106 + target_features = notmuch->features | NOTMUCH_FEATURES_CURRENT;
\r
107 + new_features = NOTMUCH_FEATURES_CURRENT & ~notmuch->features;
\r
109 - if (version >= NOTMUCH_DATABASE_VERSION)
\r
110 + if (! new_features)
\r
111 return NOTMUCH_STATUS_SUCCESS;
\r
113 if (progress_notify) {
\r
114 @@ -1239,12 +1241,11 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
115 * data field. Copy that into the new format by calling
\r
116 * notmuch_message_add_filename.
\r
118 - if (version < 1) {
\r
119 + if (new_features & NOTMUCH_FEATURE_FILE_TERMS) {
\r
120 notmuch_query_t *query = notmuch_query_create (notmuch, "");
\r
121 notmuch_messages_t *messages;
\r
122 notmuch_message_t *message;
\r
124 - Xapian::TermIterator t, t_end;
\r
126 total = notmuch_query_count_messages (query);
\r
128 @@ -1273,11 +1274,12 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
131 notmuch_query_destroy (query);
\r
134 - /* Also, before version 1 we stored directory timestamps in
\r
135 - * XTIMESTAMP documents instead of the current XDIRECTORY
\r
136 - * documents. So copy those as well. */
\r
138 + /* Also, before version 1 we stored directory timestamps in
\r
139 + * XTIMESTAMP documents instead of the current XDIRECTORY
\r
140 + * documents. So copy those as well. */
\r
141 + if (new_features & NOTMUCH_FEATURE_DIRECTORY_DOCS) {
\r
142 t_end = notmuch->xapian_db->allterms_end ("XTIMESTAMP");
\r
144 for (t = notmuch->xapian_db->allterms_begin ("XTIMESTAMP");
\r
145 @@ -1321,7 +1323,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
146 * stemmed. Change it to the current boolean prefix. Add "path:"
\r
147 * prefixes while at it.
\r
149 - if (version < 2) {
\r
150 + if (new_features & NOTMUCH_FEATURE_BOOL_FOLDER) {
\r
151 notmuch_query_t *query = notmuch_query_create (notmuch, "");
\r
152 notmuch_messages_t *messages;
\r
153 notmuch_message_t *message;
\r
154 @@ -1350,7 +1352,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
\r
155 notmuch_query_destroy (query);
\r
158 - notmuch->features |= NOTMUCH_FEATURES_CURRENT;
\r
159 + notmuch->features = target_features;
\r
160 db->set_metadata ("features", _print_features (local, notmuch->features));
\r
161 db->set_metadata ("version", STRINGIFY (NOTMUCH_DATABASE_VERSION));
\r