From 7c2fc867723e6935731992a9b518fb0d900decbc Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 27 Jul 2014 23:52:50 +2000 Subject: [PATCH] [PATCH 11/14] lib: Report progress for combined upgrade operation --- aa/a0ce93eda940aefa03d0538f50f290f048e5da | 131 ++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 aa/a0ce93eda940aefa03d0538f50f290f048e5da diff --git a/aa/a0ce93eda940aefa03d0538f50f290f048e5da b/aa/a0ce93eda940aefa03d0538f50f290f048e5da new file mode 100644 index 000000000..fa71537b3 --- /dev/null +++ b/aa/a0ce93eda940aefa03d0538f50f290f048e5da @@ -0,0 +1,131 @@ +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 14494431FBC + for ; Sat, 26 Jul 2014 20:53:36 -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 tFWTaWQdFp7I for ; + Sat, 26 Jul 2014 20:53:30 -0700 (PDT) +Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu + [18.7.68.37]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 00D35431FD0 + for ; Sat, 26 Jul 2014 20:53:08 -0700 (PDT) +X-AuditID: 12074425-f79766d000006da8-c8-53d477a26983 +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-8.mit.edu (Symantec Messaging Gateway) with SMTP + id 21.5E.28072.2A774D35; Sat, 26 Jul 2014 23:53:06 -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 s6R3r2Pf008822; + Sat, 26 Jul 2014 23:53:02 -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 s6R3r0NC016408 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sat, 26 Jul 2014 23:53:01 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1XBFW8-00051b-F2; Sat, 26 Jul 2014 23:53:00 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 11/14] lib: Report progress for combined upgrade operation +Date: Sat, 26 Jul 2014 23:52:50 -0400 +Message-Id: <1406433173-19169-12-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 2.0.0 +In-Reply-To: <1406433173-19169-1-git-send-email-amdragon@mit.edu> +References: <1406433173-19169-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixCmqrLuo/Eqwwc2N1hbXb85kdmD0eLbq + FnMAYxSXTUpqTmZZapG+XQJXxrZZn9gL7vNWHN90hrmB8T9XFyMnh4SAicTKz7fZIWwxiQv3 + 1rN1MXJxCAnMZpJ4cu0pM4SzkVHi6fSrrBDOHSaJRXu7oMrmMkq8+vqVFaSfTUBDYtv+5Ywg + toiAtMTOu7OB4hwczAJqEn+6VEBMYQEviV+tFiAVLAKqEg+mnWQBsXkFHCXmrL7CAnGFnETD + jU9sIDYnUPz4sxNsIK1CAg4Sty4lTmDkX8DIsIpRNiW3Sjc3MTOnODVZtzg5MS8vtUjXQi83 + s0QvNaV0EyMoZNhdVHcwTjikdIhRgINRiYdXgOVKsBBrYllxZe4hRkkOJiVR3v1mQCG+pPyU + yozE4oz4otKc1OJDjBIczEoivELFQDnelMTKqtSifJiUNAeLkjjvW2urYCGB9MSS1OzU1ILU + IpisDAeHkgTv11KgRsGi1PTUirTMnBKENBMHJ8hwHqDhG0BqeIsLEnOLM9Mh8qcYFaXEeX+B + JARAEhmleXC9sJh+xSgO9IowL2sZUBUPMB3Adb8CGswENJjF/zLI4JJEhJRUA2Mytz/POxbd + s4GS2v/jbXX/7mXm5TnazRRR4r2YQSHv8AUlZpkbn3z71oheu3TpwXqT7OeWnuavr25cIc41 + RfnXs0ubeCd9MPXeedho/+tdnBOjN6j37fI8F+DHEpS8+sVm1cP6PEtDZcQnmX3Z1FP/wv01 + v/WXBYWR6152TJ533v7Dh8OxptuVWIozEg21mIuKEwHpKmJ1xAIAAA== +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: Sun, 27 Jul 2014 03:53:36 -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 155cbac..a93281c 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -1240,6 +1240,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); + +@@ -1251,8 +1264,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)) +@@ -1336,6 +1347,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, + + db->delete_document (*p); + } ++ ++ ++count; + } + } + +-- +2.0.0 + -- 2.26.2