From: Austin Clements Date: Tue, 29 Jul 2014 16:48:09 +0000 (+2000) Subject: [PATCH v2 11/14] lib: Report progress for combined upgrade operation X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=031317ed6c352b9b56918b2c79fde9d80c350aac;p=notmuch-archives.git [PATCH v2 11/14] lib: Report progress for combined upgrade operation --- diff --git a/cd/945e6149a26f41366b0db1164b170a7c2af053 b/cd/945e6149a26f41366b0db1164b170a7c2af053 new file mode 100644 index 000000000..f1fed3767 --- /dev/null +++ b/cd/945e6149a26f41366b0db1164b170a7c2af053 @@ -0,0 +1,128 @@ +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 130D9431FAE + for ; Tue, 29 Jul 2014 09:48:51 -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 m-f969yuY3Cj for ; + Tue, 29 Jul 2014 09:48:45 -0700 (PDT) +Received: from dmz-mailsec-scanner-5.mit.edu (dmz-mailsec-scanner-5.mit.edu + [18.7.68.34]) + by olra.theworths.org (Postfix) with ESMTP id 3B7DA431FCB + for ; Tue, 29 Jul 2014 09:48:22 -0700 (PDT) +X-AuditID: 12074422-f79be6d000007518-ee-53d7d053c010 +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP + id B7.02.29976.350D7D35; Tue, 29 Jul 2014 12:48:19 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s6TGmIMb003296; + Tue, 29 Jul 2014 12:48:18 -0400 +Received: from drake.dyndns.org (31-33-71.wireless.csail.mit.edu + [128.31.33.71]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s6TGmF6B030270 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Tue, 29 Jul 2014 12:48:17 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1XCAZS-0007H5-VQ; Tue, 29 Jul 2014 12:48:14 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v2 11/14] lib: Report progress for combined upgrade operation +Date: Tue, 29 Jul 2014 12:48:09 -0400 +Message-Id: <1406652492-27803-12-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 2.0.0 +In-Reply-To: <1406652492-27803-1-git-send-email-amdragon@mit.edu> +References: <1406652492-27803-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixG6noht84Xqwwf8GdYvVc3ksrt+cyezA + 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZdzdtJ6p4D5vxaQ1/5kbGP9zdTFyckgImEjs + af/MAmGLSVy4t56ti5GLQ0hgNpPEutWfmSCcjYwSHbOOQjnHmCSab0yDKpvLKPFo/jZWkH42 + AQ2JbfuXM4LYIgLSEjvvzgaLMws4Snzev4gNxBYW8JU4+3g1M4jNIqAq8XHvGyYQmxeoZueu + 3UwQd8hJNNz4BFbPCRS/de8uWFxIwEHi0KzNLBMY+RcwMqxilE3JrdLNTczMKU5N1i1OTszL + Sy3SNdXLzSzRS00p3cQIDiUXpR2MPw8qHWIU4GBU4uHdMPdasBBrYllxZe4hRkkOJiVRXr19 + 14OF+JLyUyozEosz4otKc1KLDzFKcDArifDynQXK8aYkVlalFuXDpKQ5WJTEed9aWwULCaQn + lqRmp6YWpBbBZGU4OJQkeI3OAzUKFqWmp1akZeaUIKSZODhBhvMADW8GqeEtLkjMLc5Mh8if + YlSUEufNPgeUEABJZJTmwfXCYv0VozjQK8K8bSDtPMA0Adf9CmgwE9BgVhewwSWJCCmpBsa5 + SZXnUkpjWp/mLVyveXERw7+D1/ozny9YO/XyksXq4js+RJ1msv4iVm8V/KLzdb7pivXy6/Jn + yf3fMPtUtuNb2USmQ8whzdpe97+8FImSnBc47yTP34lLHzt36KUfqfb85Jgfd8H223H9y4pF + YuJxn6IvMORcncoUvmDRZ8fGMrOZqmt5/x9VYinOSDTUYi4qTgQAqD3ZWtACAAA= +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: Tue, 29 Jul 2014 16:48:51 -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 4940634..987b0a6 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); + +@@ -1245,8 +1258,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)) +@@ -1330,6 +1341,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, + + db->delete_document (*p); + } ++ ++ ++count; + } + } + +-- +2.0.0 +