From 41d202df708dd567f9616c49d08d577f89d9a0ce Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 26 Aug 2014 13:26:06 +2000 Subject: [PATCH] [PATCH v4 08/11] lib: Report progress for combined upgrade operation --- ed/20c54d6a766e0be5512774049565500cfff3a1 | 130 ++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 ed/20c54d6a766e0be5512774049565500cfff3a1 diff --git a/ed/20c54d6a766e0be5512774049565500cfff3a1 b/ed/20c54d6a766e0be5512774049565500cfff3a1 new file mode 100644 index 000000000..95c2f9d86 --- /dev/null +++ b/ed/20c54d6a766e0be5512774049565500cfff3a1 @@ -0,0 +1,130 @@ +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 0F922431FC2 + for ; Mon, 25 Aug 2014 10:26:25 -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 DI5oy0jYzQOk for ; + Mon, 25 Aug 2014 10:26:17 -0700 (PDT) +Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu + [18.7.68.35]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 905E4431FAF + for ; Mon, 25 Aug 2014 10:26:17 -0700 (PDT) +X-AuditID: 12074423-f799d6d00000337c-76-53fb71b73adf +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-6.mit.edu (Symantec Messaging Gateway) with SMTP + id CA.A0.13180.7B17BF35; Mon, 25 Aug 2014 13:26:15 -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 s7PHQE5P007796; + Mon, 25 Aug 2014 13:26:14 -0400 +Received: from drake.dyndns.org (31-35-14.wireless.csail.mit.edu + [128.31.35.14]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s7PHQCVJ029619 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Mon, 25 Aug 2014 13:26:13 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1XLy20-0003je-1S; Mon, 25 Aug 2014 13:26:12 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v4 08/11] lib: Report progress for combined upgrade operation +Date: Mon, 25 Aug 2014 13:26:06 -0400 +Message-Id: <1408987569-14146-9-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 2.0.0 +In-Reply-To: <1408987569-14146-1-git-send-email-amdragon@mit.edu> +References: <1408987569-14146-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsUixCmqrLu98HewwfwH0hY3WrsZLZqmO1tc + vzmT2YHZ49b91+wez1bdYvbYcug9cwBzFJdNSmpOZllqkb5dAlfG/sUPGAvu81a8+TaTrYHx + P1cXIyeHhICJxJXvW9ggbDGJC/fWA9lcHEICs5kklvV/YIRwNjJK7D/0mBXCOcYksXHpVXYI + Zy6jxMXpjUwg/WwCGhK/by0Gs0UEpCV23p3NCmIzC3hJLLvQD2YLC/hKXHrUwgxiswioSjzc + vRfI5uDgFXCQuHDYHeIMOYmGG5/ATuIUcJSYvnA22EghoJLvl88zT2DkX8DIsIpRNiW3Sjc3 + MTOnODVZtzg5MS8vtUjXTC83s0QvNaV0EyMouNhdlHcw/jmodIhRgINRiYf3RvzvYCHWxLLi + ytxDjJIcTEqivNPygUJ8SfkplRmJxRnxRaU5qcWHGCU4mJVEeJtBcrwpiZVVqUX5MClpDhYl + cd631lbBQgLpiSWp2ampBalFMFkZDg4lCd7cAqBGwaLU9NSKtMycEoQ0EwcnyHAeoOHxIDW8 + xQWJucWZ6RD5U4yKUuK8a0G2CoAkMkrz4Hph0f+KURzoFWHeoyDtPMDEAdf9CmgwE9Bg056f + IINLEhFSUg2MzmsaI25Yaf9zdHuS5KyddTPjWobcrVMrtq925Kl5s+n4Y/45EYvPiB7cHCJ8 + QZjr46LrpTEKx8JtonXyyvxrghdIXbtolLb6sbnfdq55R0rP2LztMmDxn9GSd/jpQsO812sT + H1/Y2RRf9G/136cLBN/a+XcFPE+Qmr9b8j63oXxN5MVdcUlCSizFGYmGWsxFxYkAbzTtD9kC AAA= +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: Mon, 25 Aug 2014 17:26:25 -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 6a7ce29..53397bb 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -1241,6 +1241,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); + +@@ -1256,8 +1269,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)) +@@ -1340,6 +1351,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, + + db->delete_document (*p); + } ++ ++ ++count; + } + } + +-- +2.0.0 + -- 2.26.2