From 74115097fd19a940f41785f28f40c7620d957804 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 7 Oct 2008 17:03:40 +0000 Subject: - gurpmi: o overall progress-bar, display the download speed, nicer looking - urpm::download::progress_text() is created out of urpm::download::sync_logger --- urpm/download.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'urpm/download.pm') diff --git a/urpm/download.pm b/urpm/download.pm index db844d41..e8c5a950 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -750,18 +750,21 @@ eval { --$wchar; }; +sub progress_text { + my ($mode, $file, $percent, $total, $eta, $speed) = @_; + $mode eq 'progress' ? + (defined $total && defined $eta ? + N(" %s%% of %s completed, ETA = %s, speed = %s", $percent, $total, $eta, $speed) : + N(" %s%% completed, speed = %s", $percent, $speed)) : ''; +} + #- default logger suitable for sync operation on STDERR only. sub sync_logger { my ($mode, $file, $percent, $total, $eta, $speed) = @_; if ($mode eq 'start') { print STDERR " $file\n"; } elsif ($mode eq 'progress') { - my $text; - if (defined $total && defined $eta) { - $text = N(" %s%% of %s completed, ETA = %s, speed = %s", $percent, $total, $eta, $speed); - } else { - $text = N(" %s%% completed, speed = %s", $percent, $speed); - } + my $text = &progress_text; if (length($text) > $wchar) { $text = substr($text, 0, $wchar) } if (bytes::length($text) < $wchar) { # clearing more than needed in case the terminal is not handling utf8 and we have a utf8 string -- cgit v1.2.1