[PATCH v3 10/13] lib: Report progress for combined upgrade operation
authorAustin Clements <amdragon@MIT.EDU>
Fri, 1 Aug 2014 02:10:00 +0000 (22:10 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:04:02 +0000 (10:04 -0800)
81/78973a1bcdb9b40dfdc8aaac3817cfc94190ee [new file with mode: 0644]

diff --git a/81/78973a1bcdb9b40dfdc8aaac3817cfc94190ee b/81/78973a1bcdb9b40dfdc8aaac3817cfc94190ee
new file mode 100644 (file)
index 0000000..ad59eab
--- /dev/null
@@ -0,0 +1,131 @@
+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 D29C3431FAE\r
+       for <notmuch@notmuchmail.org>; Thu, 31 Jul 2014 19:10:46 -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 Bte4pKNmZATJ for <notmuch@notmuchmail.org>;\r
+       Thu, 31 Jul 2014 19:10:41 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu\r
+       [18.7.68.36])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id D7B6E431FCB\r
+       for <notmuch@notmuchmail.org>; Thu, 31 Jul 2014 19:10:16 -0700 (PDT)\r
+X-AuditID: 12074424-f79146d00000067c-84-53daf708e943\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+       (using TLS with cipher AES256-SHA (256/256 bits))\r
+       (Client did not present a certificate)\r
+       by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id F5.63.01660.807FAD35; Thu, 31 Jul 2014 22:10:16 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s712AEXs014731; \r
+       Thu, 31 Jul 2014 22:10:14 -0400\r
+Received: from drake.dyndns.org\r
+       (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+       [216.15.114.40]) (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 s712ABIS030263\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Thu, 31 Jul 2014 22:10:14 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1XD2II-00033s-5c; Thu, 31 Jul 2014 22:10:06 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 10/13] lib: Report progress for combined upgrade operation\r
+Date: Thu, 31 Jul 2014 22:10:00 -0400\r
+Message-Id: <1406859003-11561-11-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 2.0.0\r
+In-Reply-To: <1406859003-11561-1-git-send-email-amdragon@mit.edu>\r
+References: <1406859003-11561-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsUixCmqrMvx/Vawwdv93Bar5/JYXL85k9mB\r
+       yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyrj68gBbwX3eiskz7jI2MP7n6mLk4JAQMJGY\r
+       eS6yi5ETyBSTuHBvPRuILSQwm0nixCntLkYuIHsjo0TDzOVMEM4dJolpO46xQThzGSU+t3wD\r
+       a2ET0JDYtn85I4gtIiAtsfPubFYQm1nAUeLz/kVsINuEBXwl9hwrBgmzCKhKzNx+HqycF6hk\r
+       37qJLBBXyEk03PgENpITKP7/3wJWiIscJFpPb2WewMi/gJFhFaNsSm6Vbm5iZk5xarJucXJi\r
+       Xl5qka65Xm5miV5qSukmRlAQsbuo7GBsPqR0iFGAg1GJh9ch9FawEGtiWXFl7iFGSQ4mJVFe\r
+       m49AIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8Lz8A5XhTEiurUovyYVLSHCxK4rxvra2ChQTS\r
+       E0tSs1NTC1KLYLIyHBxKErxnvgI1ChalpqdWpGXmlCCkmTg4QYbzAA2/BlLDW1yQmFucmQ6R\r
+       P8WoKCXOuwckIQCSyCjNg+uFRfkrRnGgV4R5H4JU8QATBFz3K6DBTECDn9+6DjK4JBEhJdXA\r
+       OFF4z5n93yVcOxln3Hi2/NDZGH3VwGI9zbr4/cvir3FNk9iyUffXnfc1B+/5Xzk/Q/ebwt60\r
+       6O6m2NY5eT38VYeeuv+bkHBo0ZzwdxumJfYZVSSaTDuYcvTm74m1PM0vXZe4nHJ+t70tqfr7\r
+       1ogfGVPqvKz/SexTPbXd6P7e+QVMtkccpy1em6PEUpyRaKjFXFScCAD+R+tfzQIAAA==\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: Fri, 01 Aug 2014 02:10:47 -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 31e6a93..04b3790 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
+@@ -1249,8 +1262,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
+@@ -1333,6 +1344,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