Re: [WIP PATCH] emacs: query: completion for from: in searches
[notmuch-archives.git] / ed / 20c54d6a766e0be5512774049565500cfff3a1
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 0F922431FC2\r
6         for <notmuch@notmuchmail.org>; Mon, 25 Aug 2014 10:26:25 -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 DI5oy0jYzQOk for <notmuch@notmuchmail.org>;\r
16         Mon, 25 Aug 2014 10:26:17 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
18         [18.7.68.35])\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 905E4431FAF\r
22         for <notmuch@notmuchmail.org>; Mon, 25 Aug 2014 10:26:17 -0700 (PDT)\r
23 X-AuditID: 12074423-f799d6d00000337c-76-53fb71b73adf\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-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id CA.A0.13180.7B17BF35; Mon, 25 Aug 2014 13:26:15 -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 s7PHQE5P007796; \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 s7PHQCVJ029619\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-0003je-1S; 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 08/11] lib: Report progress for combined upgrade operation\r
44 Date: Mon, 25 Aug 2014 13:26:06 -0400\r
45 Message-Id: <1408987569-14146-9-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+NgFjrGIsWRmVeSWpSXmKPExsUixCmqrLu98HewwfwH0hY3WrsZLZqmO1tc\r
51         vzmT2YHZ49b91+wez1bdYvbYcug9cwBzFJdNSmpOZllqkb5dAlfG/sUPGAvu81a8+TaTrYHx\r
52         P1cXIyeHhICJxJXvW9ggbDGJC/fWA9lcHEICs5kklvV/YIRwNjJK7D/0mBXCOcYksXHpVXYI\r
53         Zy6jxMXpjUwg/WwCGhK/by0Gs0UEpCV23p3NCmIzC3hJLLvQD2YLC/hKXHrUwgxiswioSjzc\r
54         vRfI5uDgFXCQuHDYHeIMOYmGG5/ATuIUcJSYvnA22EghoJLvl88zT2DkX8DIsIpRNiW3Sjc3\r
55         MTOnODVZtzg5MS8vtUjXTC83s0QvNaV0EyMouNhdlHcw/jmodIhRgINRiYf3RvzvYCHWxLLi\r
56         ytxDjJIcTEqivNPygUJ8SfkplRmJxRnxRaU5qcWHGCU4mJVEeJtBcrwpiZVVqUX5MClpDhYl\r
57         cd631lbBQgLpiSWp2ampBalFMFkZDg4lCd7cAqBGwaLU9NSKtMycEoQ0EwcnyHAeoOHxIDW8\r
58         xQWJucWZ6RD5U4yKUuK8a0G2CoAkMkrz4Hph0f+KURzoFWHeoyDtPMDEAdf9CmgwE9Bg056f\r
59         IINLEhFSUg2MzmsaI25Yaf9zdHuS5KyddTPjWobcrVMrtq925Kl5s+n4Y/45EYvPiB7cHCJ8\r
60         QZjr46LrpTEKx8JtonXyyvxrghdIXbtolLb6sbnfdq55R0rP2LztMmDxn9GSd/jpQsO812sT\r
61         H1/Y2RRf9G/136cLBN/a+XcFPE+Qmr9b8j63oXxN5MVdcUlCSizFGYmGWsxFxYkAbzTtD9kC        AAA=\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.13\r
64 Precedence: list\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: Mon, 25 Aug 2014 17:26:25 -0000\r
75 \r
76 Previously, some parts of upgrade didn't report progress and for\r
77 others it was possible for the progress meter to restart at 0 part way\r
78 through the upgrade because each stage was reported separately.\r
79 \r
80 Fix this by computing the total amount of work that needs to be done\r
81 up-front and updating completed work monotonically.\r
82 ---\r
83  lib/database.cc | 17 +++++++++++++++--\r
84  1 file changed, 15 insertions(+), 2 deletions(-)\r
85 \r
86 diff --git a/lib/database.cc b/lib/database.cc\r
87 index 6a7ce29..53397bb 100644\r
88 --- a/lib/database.cc\r
89 +++ b/lib/database.cc\r
90 @@ -1241,6 +1241,19 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
91         timer_is_active = TRUE;\r
92      }\r
93  \r
94 +    /* Figure out how much total work we need to do. */\r
95 +    if (new_features &\r
96 +       (NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_BOOL_FOLDER)) {\r
97 +       notmuch_query_t *query = notmuch_query_create (notmuch, "");\r
98 +       total += notmuch_query_count_messages (query);\r
99 +       notmuch_query_destroy (query);\r
100 +    }\r
101 +    if (new_features & NOTMUCH_FEATURE_DIRECTORY_DOCS) {\r
102 +       t_end = db->allterms_end ("XTIMESTAMP");\r
103 +       for (t = db->allterms_begin ("XTIMESTAMP"); t != t_end; t++)\r
104 +           ++total;\r
105 +    }\r
106 +\r
107      /* Perform the upgrade in a transaction. */\r
108      db->begin_transaction (true);\r
109  \r
110 @@ -1256,8 +1269,6 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
111         notmuch_message_t *message;\r
112         char *filename;\r
113  \r
114 -       total = notmuch_query_count_messages (query);\r
115 -\r
116         for (messages = notmuch_query_search_messages (query);\r
117              notmuch_messages_valid (messages);\r
118              notmuch_messages_move_to_next (messages))\r
119 @@ -1340,6 +1351,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
120  \r
121                 db->delete_document (*p);\r
122             }\r
123 +\r
124 +           ++count;\r
125         }\r
126      }\r
127  \r
128 -- \r
129 2.0.0\r
130 \r