]> granicus.if.org Git - pgbadger/commitdiff
Prevent progress bar length to increase after 100% when real size is greater than...
authorDarold Gilles <gilles@darold.net>
Mon, 4 Nov 2013 18:09:04 +0000 (19:09 +0100)
committerDarold Gilles <gilles@darold.net>
Mon, 4 Nov 2013 18:09:04 +0000 (19:09 +0100)
pgbadger

index 16289ff3a2cb73afd4b432ea0b0be5ab08dec667..902bce9b4314412dc300f881e5628720b020ec42 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -8039,10 +8039,12 @@ sub progress_bar
        $width ||= 25;
        $char  ||= '=';
        my $num_width = length $total;
+       my $nchars = (($width - 1) * $got / $total);
+       $nchars = ($width - 1) if ($nchars >= $width);
        if ($extension eq 'tsung') {
                sprintf(
                        "[%-${width}s] Parsed %${num_width}s bytes of %s (%.2f%%), queries: %d\r",
-                       $char x (($width - 1) * $got / $total) . '>',
+                       $char x $nchars . '>',
                        $got, $total, 100 * $got / +$total, ($queries || $tsung_queries)
                );
        } elsif($format eq 'binary') {
@@ -8054,7 +8056,7 @@ sub progress_bar
        } else {
                sprintf(
                        "[%-${width}s] Parsed %${num_width}s bytes of %s (%.2f%%), queries: %d, events: %d\r",
-                       $char x (($width - 1) * $got / $total) . '>',
+                       $char x $nchars . '>',
                        $got, $total, 100 * $got / +$total, ($queries || $overall_stat{'queries_number'}), ($errors || $overall_stat{'errors_number'})
                );
        }