Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id D29C3431FAE for ; Thu, 31 Jul 2014 19:10:46 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.3 X-Spam-Level: X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Bte4pKNmZATJ for ; Thu, 31 Jul 2014 19:10:41 -0700 (PDT) Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu [18.7.68.36]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D7B6E431FCB for ; Thu, 31 Jul 2014 19:10:16 -0700 (PDT) X-AuditID: 12074424-f79146d00000067c-84-53daf708e943 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP id F5.63.01660.807FAD35; Thu, 31 Jul 2014 22:10:16 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s712AEXs014731; Thu, 31 Jul 2014 22:10:14 -0400 Received: from drake.dyndns.org (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [216.15.114.40]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s712ABIS030263 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 31 Jul 2014 22:10:14 -0400 Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1XD2II-00033s-5c; Thu, 31 Jul 2014 22:10:06 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v3 10/13] lib: Report progress for combined upgrade operation Date: Thu, 31 Jul 2014 22:10:00 -0400 Message-Id: <1406859003-11561-11-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1406859003-11561-1-git-send-email-amdragon@mit.edu> References: <1406859003-11561-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsUixCmqrMvx/Vawwdv93Bar5/JYXL85k9mB yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyrj68gBbwX3eiskz7jI2MP7n6mLk4JAQMJGY eS6yi5ETyBSTuHBvPRuILSQwm0nixCntLkYuIHsjo0TDzOVMEM4dJolpO46xQThzGSU+t3wD a2ET0JDYtn85I4gtIiAtsfPubFYQm1nAUeLz/kVsINuEBXwl9hwrBgmzCKhKzNx+HqycF6hk 37qJLBBXyEk03PgENpITKP7/3wJWiIscJFpPb2WewMi/gJFhFaNsSm6Vbm5iZk5xarJucXJi Xl5qka65Xm5miV5qSukmRlAQsbuo7GBsPqR0iFGAg1GJh9ch9FawEGtiWXFl7iFGSQ4mJVFe m49AIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8Lz8A5XhTEiurUovyYVLSHCxK4rxvra2ChQTS E0tSs1NTC1KLYLIyHBxKErxnvgI1ChalpqdWpGXmlCCkmTg4QYbzAA2/BlLDW1yQmFucmQ6R P8WoKCXOuwckIQCSyCjNg+uFRfkrRnGgV4R5H4JU8QATBFz3K6DBTECDn9+6DjK4JBEhJdXA OFF4z5n93yVcOxln3Hi2/NDZGH3VwGI9zbr4/cvir3FNk9iyUffXnfc1B+/5Xzk/Q/ebwt60 6O6m2NY5eT38VYeeuv+bkHBo0ZzwdxumJfYZVSSaTDuYcvTm74m1PM0vXZe4nHJ+t70tqfr7 1ogfGVPqvKz/SexTPbXd6P7e+QVMtkccpy1em6PEUpyRaKjFXFScCAD+R+tfzQIAAA== X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Aug 2014 02:10:47 -0000 Previously, some parts of upgrade didn't report progress and for others it was possible for the progress meter to restart at 0 part way through the upgrade because each stage was reported separately. Fix this by computing the total amount of work that needs to be done up-front and updating completed work monotonically. --- lib/database.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 31e6a93..04b3790 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -1234,6 +1234,19 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, timer_is_active = TRUE; } + /* Figure out how much total work we need to do. */ + if (new_features & + (NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_BOOL_FOLDER)) { + notmuch_query_t *query = notmuch_query_create (notmuch, ""); + total += notmuch_query_count_messages (query); + notmuch_query_destroy (query); + } + if (new_features & NOTMUCH_FEATURE_DIRECTORY_DOCS) { + t_end = db->allterms_end ("XTIMESTAMP"); + for (t = db->allterms_begin ("XTIMESTAMP"); t != t_end; t++) + ++total; + } + /* Perform the upgrade in a transaction. */ db->begin_transaction (true); @@ -1249,8 +1262,6 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, notmuch_message_t *message; char *filename; - total = notmuch_query_count_messages (query); - for (messages = notmuch_query_search_messages (query); notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) @@ -1333,6 +1344,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, db->delete_document (*p); } + + ++count; } } -- 2.0.0