summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-03-03 12:46:07 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-03-03 12:46:07 +0000
commit2da9497b3f0bcf989fb8767a6662737b6a9ef637 (patch)
tree027d5798f9f8f81ad711092ec8a57fd97831e513
parent42ae1a540a742a0ab6c5525f59adf1fb84a9db26 (diff)
downloadurpmi-2da9497b3f0bcf989fb8767a6662737b6a9ef637.tar
urpmi-2da9497b3f0bcf989fb8767a6662737b6a9ef637.tar.gz
urpmi-2da9497b3f0bcf989fb8767a6662737b6a9ef637.tar.bz2
urpmi-2da9497b3f0bcf989fb8767a6662737b6a9ef637.tar.xz
urpmi-2da9497b3f0bcf989fb8767a6662737b6a9ef637.zip
fix download progression using wget:
- the first line displays the date, not simply the time - the "==> RETR" is only for ftp, also parse "200 OK" - detecting size using /^Length/ is much simpler when wget output is not translated, so use LC_ALL=C - "ETA" is now "eta" in my tests - "eta" is not displayed at the beginning, do call propagate_sync_callback with precent and speed
-rw-r--r--NEWS1
-rw-r--r--urpm/download.pm16
2 files changed, 10 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index f2cbb4e9..982eaaa5 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@
o cdrom:// replaces removable://
o use hal to wait-for/mount cdroms:
you can now use more than one cdrom drive
+ o fix download progression using wget
- urpmf, urpmq:
o do not try to download xml-info if it's not available (#38125)
- urpmi.addmedia:
diff --git a/urpm/download.pm b/urpm/download.pm
index 63847ca7..9ccd2f2b 100644
--- a/urpm/download.pm
+++ b/urpm/download.pm
@@ -262,6 +262,7 @@ sub sync_wget {
@_
) . " |";
$options->{debug} and $options->{debug}($wget_command);
+ local $ENV{LC_ALL} = 'C';
my $wget_pid = open(my $wget, $wget_command);
local $/ = \1; #- read input by only one char, this is slow but very nice (and it works!).
local $_;
@@ -269,18 +270,19 @@ sub sync_wget {
$buf .= $_;
if ($_ eq "\r" || $_ eq "\n") {
if ($options->{callback}) {
- if ($buf =~ /^--\d\d:\d\d:\d\d--\s+(\S.*)\n/ms) {
- if ($file && $file ne $1) {
+ if ($buf =~ /^--(\d\d\d\d-\d\d-\d\d )?\d\d:\d\d:\d\d--\s+(\S.*)\n/ms) {
+ my $file_ = $2;
+ if ($file && $file ne $file_) {
propagate_sync_callback($options, 'end', $file);
undef $file;
}
- ! defined $file and propagate_sync_callback($options, 'start', $file = $1);
- } elsif (defined $file && ! defined $total && $buf =~ /==>\s+RETR/) {
+ ! defined $file and propagate_sync_callback($options, 'start', $file = $file_);
+ } elsif (defined $file && ! defined $total && ($buf =~ /==>\s+RETR/ || $buf =~ /200 OK$/)) {
$total = '';
- } elsif (defined $total && $total eq '' && $buf =~ /^[^:]*:\s+(\d\S*)/) {
+ } elsif ($buf =~ /^Length:\s*(\d\S*)/) {
$total = $1;
- } elsif (defined $total && $buf =~ /^\s*(\d+)%.*\s+(\S+)\s+ETA\s+(\S+)\s*[\r\n]$/ms) {
- my ($percent, $speed, $eta) = ($1, $2, $3);
+ } elsif (defined $total && $buf =~ m!^\s*(\d+)%.*\s+(\S+/s)\s+((ETA|eta)\s+(.*?)\s*)?[\r\n]$!ms) {
+ my ($percent, $speed, $eta) = ($1, $2, $5);
if (propagate_sync_callback($options, 'progress', $file, $percent, $total, $eta, $speed) eq 'canceled') {
kill 15, $wget_pid;
close $wget;