summaryrefslogtreecommitdiffstats
path: root/urpm/download.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-10-07 17:03:40 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-10-07 17:03:40 +0000
commit74115097fd19a940f41785f28f40c7620d957804 (patch)
treee127e20d95720b69952ded4544b40ff987304d0d /urpm/download.pm
parentce08405069bef2e018a1cdfd9b8706725678af67 (diff)
downloadurpmi-74115097fd19a940f41785f28f40c7620d957804.tar
urpmi-74115097fd19a940f41785f28f40c7620d957804.tar.gz
urpmi-74115097fd19a940f41785f28f40c7620d957804.tar.bz2
urpmi-74115097fd19a940f41785f28f40c7620d957804.tar.xz
urpmi-74115097fd19a940f41785f28f40c7620d957804.zip
- gurpmi:
o overall progress-bar, display the download speed, nicer looking - urpm::download::progress_text() is created out of urpm::download::sync_logger
Diffstat (limited to 'urpm/download.pm')
-rw-r--r--urpm/download.pm15
1 files changed, 9 insertions, 6 deletions
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