From 7d96f7884e951b82d23e5a252357efd8b3192f45 Mon Sep 17 00:00:00 2001 From: "Tomas V.V.Cox" Date: Thu, 11 Sep 2003 14:47:03 +0000 Subject: [PATCH] Be more nice when downloading files --- pear/PEAR/Command/Install.php | 1 - pear/PEAR/Common.php | 6 +++--- pear/PEAR/Frontend/CLI.php | 7 +++++-- pear/PEAR/Installer.php | 13 +++++++++++++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php index bc0e95803b..9cac11a058 100644 --- a/pear/PEAR/Command/Install.php +++ b/pear/PEAR/Command/Install.php @@ -20,7 +20,6 @@ require_once "PEAR/Command/Common.php"; require_once "PEAR/Installer.php"; -require_once "Console/Getopt.php"; /** * PEAR commands for installation or deinstallation/upgrading of diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index f34b25f8c3..e9f43ba2f6 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -217,11 +217,11 @@ class PEAR_Common extends PEAR * * @access public */ - function log($level, $msg) + function log($level, $msg, $append_crlf = true) { if ($this->debug >= $level) { if (is_object($this->ui)) { - $this->ui->log($msg); + $this->ui->log($msg, $append_crlf); } else { print "$msg\n"; } @@ -1699,7 +1699,7 @@ class PEAR_Common extends PEAR } $bytes = 0; if ($callback) { - call_user_func($callback, 'start', $length); + call_user_func($callback, 'start', array(basename($dest_file), $length)); } while ($data = @fread($fp, 1024)) { $bytes += strlen($data); diff --git a/pear/PEAR/Frontend/CLI.php b/pear/PEAR/Frontend/CLI.php index 81326d27b4..7604077d46 100644 --- a/pear/PEAR/Frontend/CLI.php +++ b/pear/PEAR/Frontend/CLI.php @@ -472,9 +472,12 @@ class PEAR_Frontend_CLI extends PEAR // {{{ log(text) - function log($text) + function log($text, $append_crlf = true) { - return $this->_displayLine($text); + if ($append_crlf) { + return $this->_displayLine($text); + } + return $this->_display($text); } diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index dfeb0f3db3..3e026cba2e 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -1189,6 +1189,19 @@ class PEAR_Installer extends PEAR_Common case 'done': $this->log(1, '...done: ' . number_format($params, 0, '', ',') . ' bytes'); break; + case 'bytesread': + static $bytes; + if (empty($bytes)) { + $bytes = 0; + } + if (!($bytes % 10240)) { + $this->log(1, '.', false); + } + $bytes += $params; + break; + case 'start': + $this->log(1, "Starting to download {$params[0]} (".number_format($params[1], 0, '', ',')." bytes)"); + break; } if (method_exists($this->ui, '_downloadCallback')) $this->ui->_downloadCallback($msg, $params); -- 2.50.1