--- /dev/null
+Return-Path: <sojkam1@fel.cvut.cz>\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 BE106431FB6\r
+ for <notmuch@notmuchmail.org>; Wed, 26 Jan 2011 05:07:13 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 mfj8blWFGAG0 for <notmuch@notmuchmail.org>;\r
+ Wed, 26 Jan 2011 05:07:13 -0800 (PST)\r
+Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
+ by olra.theworths.org (Postfix) with ESMTP id 2369F431FB5\r
+ for <notmuch@notmuchmail.org>; Wed, 26 Jan 2011 05:07:13 -0800 (PST)\r
+Received: from localhost (unknown [192.168.200.4])\r
+ by max.feld.cvut.cz (Postfix) with ESMTP id 79FE919F3327;\r
+ Wed, 26 Jan 2011 14:07:11 +0100 (CET)\r
+X-Virus-Scanned: IMAP AMAVIS\r
+Received: from max.feld.cvut.cz ([192.168.200.1])\r
+ by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,\r
+ port 10044)\r
+ with ESMTP id APQ4JujjJ-pM; Wed, 26 Jan 2011 14:07:10 +0100 (CET)\r
+Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
+ by max.feld.cvut.cz (Postfix) with ESMTP id DA67319F3329;\r
+ Wed, 26 Jan 2011 14:07:09 +0100 (CET)\r
+Received: from steelpick.2x.cz (note-sojka.felk.cvut.cz [147.32.86.30])\r
+ (Authenticated sender: sojkam1)\r
+ by imap.feld.cvut.cz (Postfix) with ESMTPSA id DF4DA15C031;\r
+ Wed, 26 Jan 2011 14:07:09 +0100 (CET)\r
+Received: from wsh by steelpick.2x.cz with local (Exim 4.72)\r
+ (envelope-from <sojkam1@fel.cvut.cz>)\r
+ id 1Pi55Z-0001ti-AN; Wed, 26 Jan 2011 14:07:09 +0100\r
+From: Michal Sojka <sojkam1@fel.cvut.cz>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] new: Print progress estimates only when we have sufficient\r
+ information\r
+Date: Wed, 26 Jan 2011 14:06:57 +0100\r
+Message-Id: <1296047217-7266-1-git-send-email-sojkam1@fel.cvut.cz>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <1295603977-14326-5-git-send-email-sojkam1@fel.cvut.cz>\r
+References: <1295603977-14326-5-git-send-email-sojkam1@fel.cvut.cz>\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: Wed, 26 Jan 2011 13:07:13 -0000\r
+\r
+Without this patch, it might happen that the remaining time or processing\r
+rate were calculated just after start where nothing was processed yet.\r
+This resulted into division by a very small number (or zero) and the\r
+printed information was of little value.\r
+\r
+Instead of printing nonsenses we print only that the operation is in\r
+progress. The estimates will be printed later, after there is enough data.\r
+---\r
+ notmuch-new.c | 18 +++++++++++-------\r
+ 1 files changed, 11 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index fa7a76d..8f64b25 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -117,15 +117,19 @@ generic_print_progress (const char *action, const char *object,\r
+ printf ("%s %d ", action, processed);\r
+ \r
+ if (total) {\r
+- double time_remaining;\r
+-\r
+- time_remaining = ((total - processed) / rate_overall);\r
+- printf ("of %d %s (", total, object);\r
+- notmuch_time_print_formatted_seconds (time_remaining);\r
+- printf (" remaining).\033[K\r");\r
++ printf ("of %d %s", total, object);\r
++ if (processed > 0 && elapsed_overall > 0.5) {\r
++ double time_remaining = ((total - processed) / rate_overall);\r
++ printf (" (");\r
++ notmuch_time_print_formatted_seconds (time_remaining);\r
++ printf (" remaining)");\r
++ }\r
+ } else {\r
+- printf ("%s (%d %s/sec.)\033[K\r", object, (int) rate_overall, object);\r
++ printf ("%s", object);\r
++ if (elapsed_overall > 0.5)\r
++ printf (" (%d %s/sec.)", (int) rate_overall, object);\r
+ }\r
++ printf (".\033[K\r");\r
+ \r
+ fflush (stdout);\r
+ }\r
+-- \r
+1.7.2.3\r
+\r