Re: Hi all
[notmuch-archives.git] / aa / a0ce93eda940aefa03d0538f50f290f048e5da
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 14494431FBC\r
6         for <notmuch@notmuchmail.org>; Sat, 26 Jul 2014 20:53:36 -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 tFWTaWQdFp7I for <notmuch@notmuchmail.org>;\r
16         Sat, 26 Jul 2014 20:53:30 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu\r
18         [18.7.68.37])\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 00D35431FD0\r
22         for <notmuch@notmuchmail.org>; Sat, 26 Jul 2014 20:53:08 -0700 (PDT)\r
23 X-AuditID: 12074425-f79766d000006da8-c8-53d477a26983\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-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id 21.5E.28072.2A774D35; Sat, 26 Jul 2014 23:53:06 -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 s6R3r2Pf008822; \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 s6R3r0NC016408\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-00051b-F2; 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 11/14] lib: Report progress for combined upgrade operation\r
45 Date: Sat, 26 Jul 2014 23:52:50 -0400\r
46 Message-Id: <1406433173-19169-12-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+NgFtrIIsWRmVeSWpSXmKPExsUixCmqrLuo/Eqwwc2N1hbXb85kdmD0eLbq\r
52         FnMAYxSXTUpqTmZZapG+XQJXxrZZn9gL7vNWHN90hrmB8T9XFyMnh4SAicTKz7fZIWwxiQv3\r
53         1rN1MXJxCAnMZpJ4cu0pM4SzkVHi6fSrrBDOHSaJRXu7oMrmMkq8+vqVFaSfTUBDYtv+5Ywg\r
54         toiAtMTOu7OB4hwczAJqEn+6VEBMYQEviV+tFiAVLAKqEg+mnWQBsXkFHCXmrL7CAnGFnETD\r
55         jU9sIDYnUPz4sxNsIK1CAg4Sty4lTmDkX8DIsIpRNiW3Sjc3MTOnODVZtzg5MS8vtUjXQi83\r
56         s0QvNaV0EyMoZNhdVHcwTjikdIhRgINRiYdXgOVKsBBrYllxZe4hRkkOJiVR3v1mQCG+pPyU\r
57         yozE4oz4otKc1OJDjBIczEoivELFQDnelMTKqtSifJiUNAeLkjjvW2urYCGB9MSS1OzU1ILU\r
58         IpisDAeHkgTv11KgRsGi1PTUirTMnBKENBMHJ8hwHqDhG0BqeIsLEnOLM9Mh8qcYFaXEeX+B\r
59         JARAEhmleXC9sJh+xSgO9IowL2sZUBUPMB3Adb8CGswENJjF/zLI4JJEhJRUA2Mytz/POxbd\r
60         s4GS2v/jbXX/7mXm5TnazRRR4r2YQSHv8AUlZpkbn3z71oheu3TpwXqT7OeWnuavr25cIc41\r
61         RfnXs0ubeCd9MPXeedho/+tdnBOjN6j37fI8F+DHEpS8+sVm1cP6PEtDZcQnmX3Z1FP/wv01\r
62         v/WXBYWR6152TJ533v7Dh8OxptuVWIozEg21mIuKEwHpKmJ1xAIAAA==\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: Sun, 27 Jul 2014 03:53:36 -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 155cbac..a93281c 100644\r
89 --- a/lib/database.cc\r
90 +++ b/lib/database.cc\r
91 @@ -1240,6 +1240,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 @@ -1251,8 +1264,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 @@ -1336,6 +1347,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