Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / 81 / 78973a1bcdb9b40dfdc8aaac3817cfc94190ee
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 D29C3431FAE\r
6         for <notmuch@notmuchmail.org>; Thu, 31 Jul 2014 19:10:46 -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: -2.3\r
10 X-Spam-Level: \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 Bte4pKNmZATJ for <notmuch@notmuchmail.org>;\r
16         Thu, 31 Jul 2014 19:10:41 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu\r
18         [18.7.68.36])\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 D7B6E431FCB\r
22         for <notmuch@notmuchmail.org>; Thu, 31 Jul 2014 19:10:16 -0700 (PDT)\r
23 X-AuditID: 12074424-f79146d00000067c-84-53daf708e943\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-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id F5.63.01660.807FAD35; Thu, 31 Jul 2014 22:10:16 -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 s712AEXs014731; \r
31         Thu, 31 Jul 2014 22:10:14 -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 s712ABIS030263\r
37         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
38         Thu, 31 Jul 2014 22:10:14 -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 1XD2II-00033s-5c; Thu, 31 Jul 2014 22:10:06 -0400\r
42 From: Austin Clements <amdragon@MIT.EDU>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH v3 10/13] lib: Report progress for combined upgrade operation\r
45 Date: Thu, 31 Jul 2014 22:10:00 -0400\r
46 Message-Id: <1406859003-11561-11-git-send-email-amdragon@mit.edu>\r
47 X-Mailer: git-send-email 2.0.0\r
48 In-Reply-To: <1406859003-11561-1-git-send-email-amdragon@mit.edu>\r
49 References: <1406859003-11561-1-git-send-email-amdragon@mit.edu>\r
50 X-Brightmail-Tracker:\r
51  H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsUixCmqrMvx/Vawwdv93Bar5/JYXL85k9mB\r
52         yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyrj68gBbwX3eiskz7jI2MP7n6mLk4JAQMJGY\r
53         eS6yi5ETyBSTuHBvPRuILSQwm0nixCntLkYuIHsjo0TDzOVMEM4dJolpO46xQThzGSU+t3wD\r
54         a2ET0JDYtn85I4gtIiAtsfPubFYQm1nAUeLz/kVsINuEBXwl9hwrBgmzCKhKzNx+HqycF6hk\r
55         37qJLBBXyEk03PgENpITKP7/3wJWiIscJFpPb2WewMi/gJFhFaNsSm6Vbm5iZk5xarJucXJi\r
56         Xl5qka65Xm5miV5qSukmRlAQsbuo7GBsPqR0iFGAg1GJh9ch9FawEGtiWXFl7iFGSQ4mJVFe\r
57         m49AIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8Lz8A5XhTEiurUovyYVLSHCxK4rxvra2ChQTS\r
58         E0tSs1NTC1KLYLIyHBxKErxnvgI1ChalpqdWpGXmlCCkmTg4QYbzAA2/BlLDW1yQmFucmQ6R\r
59         P8WoKCXOuwckIQCSyCjNg+uFRfkrRnGgV4R5H4JU8QATBFz3K6DBTECDn9+6DjK4JBEhJdXA\r
60         OFF4z5n93yVcOxln3Hi2/NDZGH3VwGI9zbr4/cvir3FNk9iyUffXnfc1B+/5Xzk/Q/ebwt60\r
61         6O6m2NY5eT38VYeeuv+bkHBo0ZzwdxumJfYZVSSaTDuYcvTm74m1PM0vXZe4nHJ+t70tqfr7\r
62         1ogfGVPqvKz/SexTPbXd6P7e+QVMtkccpy1em6PEUpyRaKjFXFScCAD+R+tfzQIAAA==\r
63 X-BeenThere: notmuch@notmuchmail.org\r
64 X-Mailman-Version: 2.1.13\r
65 Precedence: list\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: Fri, 01 Aug 2014 02:10:47 -0000\r
76 \r
77 Previously, some parts of upgrade didn't report progress and for\r
78 others it was possible for the progress meter to restart at 0 part way\r
79 through the upgrade because each stage was reported separately.\r
80 \r
81 Fix this by computing the total amount of work that needs to be done\r
82 up-front and updating completed work monotonically.\r
83 ---\r
84  lib/database.cc | 17 +++++++++++++++--\r
85  1 file changed, 15 insertions(+), 2 deletions(-)\r
86 \r
87 diff --git a/lib/database.cc b/lib/database.cc\r
88 index 31e6a93..04b3790 100644\r
89 --- a/lib/database.cc\r
90 +++ b/lib/database.cc\r
91 @@ -1234,6 +1234,19 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
92         timer_is_active = TRUE;\r
93      }\r
94  \r
95 +    /* Figure out how much total work we need to do. */\r
96 +    if (new_features &\r
97 +       (NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_BOOL_FOLDER)) {\r
98 +       notmuch_query_t *query = notmuch_query_create (notmuch, "");\r
99 +       total += notmuch_query_count_messages (query);\r
100 +       notmuch_query_destroy (query);\r
101 +    }\r
102 +    if (new_features & NOTMUCH_FEATURE_DIRECTORY_DOCS) {\r
103 +       t_end = db->allterms_end ("XTIMESTAMP");\r
104 +       for (t = db->allterms_begin ("XTIMESTAMP"); t != t_end; t++)\r
105 +           ++total;\r
106 +    }\r
107 +\r
108      /* Perform the upgrade in a transaction. */\r
109      db->begin_transaction (true);\r
110  \r
111 @@ -1249,8 +1262,6 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
112         notmuch_message_t *message;\r
113         char *filename;\r
114  \r
115 -       total = notmuch_query_count_messages (query);\r
116 -\r
117         for (messages = notmuch_query_search_messages (query);\r
118              notmuch_messages_valid (messages);\r
119              notmuch_messages_move_to_next (messages))\r
120 @@ -1333,6 +1344,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
121  \r
122                 db->delete_document (*p);\r
123             }\r
124 +\r
125 +           ++count;\r
126         }\r
127      }\r
128  \r
129 -- \r
130 2.0.0\r
131 \r