[PATCH v2 11/14] lib: Report progress for combined upgrade operation
authorAustin Clements <amdragon@MIT.EDU>
Tue, 29 Jul 2014 16:48:09 +0000 (12:48 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:03:57 +0000 (10:03 -0800)
cd/945e6149a26f41366b0db1164b170a7c2af053 [new file with mode: 0644]

diff --git a/cd/945e6149a26f41366b0db1164b170a7c2af053 b/cd/945e6149a26f41366b0db1164b170a7c2af053
new file mode 100644 (file)
index 0000000..f1fed37
--- /dev/null
@@ -0,0 +1,128 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 130D9431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 29 Jul 2014 09:48:51 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id m-f969yuY3Cj for <notmuch@notmuchmail.org>;\r
+       Tue, 29 Jul 2014 09:48:45 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-5.mit.edu (dmz-mailsec-scanner-5.mit.edu\r
+       [18.7.68.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 3B7DA431FCB\r
+       for <notmuch@notmuchmail.org>; Tue, 29 Jul 2014 09:48:22 -0700 (PDT)\r
+X-AuditID: 12074422-f79be6d000007518-ee-53d7d053c010\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       (using TLS with cipher AES256-SHA (256/256 bits))\r
+       (Client did not present a certificate)\r
+       by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id B7.02.29976.350D7D35; Tue, 29 Jul 2014 12:48:19 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s6TGmIMb003296; \r
+       Tue, 29 Jul 2014 12:48:18 -0400\r
+Received: from drake.dyndns.org (31-33-71.wireless.csail.mit.edu\r
+       [128.31.33.71]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s6TGmF6B030270\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Tue, 29 Jul 2014 12:48:17 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1XCAZS-0007H5-VQ; Tue, 29 Jul 2014 12:48:14 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 11/14] lib: Report progress for combined upgrade operation\r
+Date: Tue, 29 Jul 2014 12:48:09 -0400\r
+Message-Id: <1406652492-27803-12-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 2.0.0\r
+In-Reply-To: <1406652492-27803-1-git-send-email-amdragon@mit.edu>\r
+References: <1406652492-27803-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixG6noht84Xqwwf8GdYvVc3ksrt+cyezA\r
+       5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZdzdtJ6p4D5vxaQ1/5kbGP9zdTFyckgImEjs\r
+       af/MAmGLSVy4t56ti5GLQ0hgNpPEutWfmSCcjYwSHbOOQjnHmCSab0yDKpvLKPFo/jZWkH42\r
+       AQ2JbfuXM4LYIgLSEjvvzgaLMws4Snzev4gNxBYW8JU4+3g1M4jNIqAq8XHvGyYQmxeoZueu\r
+       3UwQd8hJNNz4BFbPCRS/de8uWFxIwEHi0KzNLBMY+RcwMqxilE3JrdLNTczMKU5N1i1OTszL\r
+       Sy3SNdXLzSzRS00p3cQIDiUXpR2MPw8qHWIU4GBU4uHdMPdasBBrYllxZe4hRkkOJiVRXr19\r
+       14OF+JLyUyozEosz4otKc1KLDzFKcDArifDynQXK8aYkVlalFuXDpKQ5WJTEed9aWwULCaQn\r
+       lqRmp6YWpBbBZGU4OJQkeI3OAzUKFqWmp1akZeaUIKSZODhBhvMADW8GqeEtLkjMLc5Mh8if\r
+       YlSUEufNPgeUEABJZJTmwfXCYv0VozjQK8K8bSDtPMA0Adf9CmgwE9BgVhewwSWJCCmpBsa5\r
+       SZXnUkpjWp/mLVyveXERw7+D1/ozny9YO/XyksXq4js+RJ1msv4iVm8V/KLzdb7pivXy6/Jn\r
+       yf3fMPtUtuNb2USmQ8whzdpe97+8FImSnBc47yTP34lLHzt36KUfqfb85Jgfd8H223H9y4pF\r
+       YuJxn6IvMORcncoUvmDRZ8fGMrOZqmt5/x9VYinOSDTUYi4qTgQAqD3ZWtACAAA=\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 29 Jul 2014 16:48:51 -0000\r
+\r
+Previously, some parts of upgrade didn't report progress and for\r
+others it was possible for the progress meter to restart at 0 part way\r
+through the upgrade because each stage was reported separately.\r
+\r
+Fix this by computing the total amount of work that needs to be done\r
+up-front and updating completed work monotonically.\r
+---\r
+ lib/database.cc | 17 +++++++++++++++--\r
+ 1 file changed, 15 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 4940634..987b0a6 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -1234,6 +1234,19 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
+       timer_is_active = TRUE;\r
+     }\r
\r
++    /* Figure out how much total work we need to do. */\r
++    if (new_features &\r
++      (NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_BOOL_FOLDER)) {\r
++      notmuch_query_t *query = notmuch_query_create (notmuch, "");\r
++      total += notmuch_query_count_messages (query);\r
++      notmuch_query_destroy (query);\r
++    }\r
++    if (new_features & NOTMUCH_FEATURE_DIRECTORY_DOCS) {\r
++      t_end = db->allterms_end ("XTIMESTAMP");\r
++      for (t = db->allterms_begin ("XTIMESTAMP"); t != t_end; t++)\r
++          ++total;\r
++    }\r
++\r
+     /* Perform the upgrade in a transaction. */\r
+     db->begin_transaction (true);\r
\r
+@@ -1245,8 +1258,6 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
+       notmuch_message_t *message;\r
+       char *filename;\r
\r
+-      total = notmuch_query_count_messages (query);\r
+-\r
+       for (messages = notmuch_query_search_messages (query);\r
+            notmuch_messages_valid (messages);\r
+            notmuch_messages_move_to_next (messages))\r
+@@ -1330,6 +1341,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
\r
+               db->delete_document (*p);\r
+           }\r
++\r
++          ++count;\r
+       }\r
+     }\r
\r
+-- \r
+2.0.0\r
+\r