]> granicus.if.org Git - php/commitdiff
Be more nice when downloading files
authorTomas V.V.Cox <cox@php.net>
Thu, 11 Sep 2003 14:47:03 +0000 (14:47 +0000)
committerTomas V.V.Cox <cox@php.net>
Thu, 11 Sep 2003 14:47:03 +0000 (14:47 +0000)
pear/PEAR/Command/Install.php
pear/PEAR/Common.php
pear/PEAR/Frontend/CLI.php
pear/PEAR/Installer.php

index bc0e95803bb2f4f913ac17e41c6e53a56b550983..9cac11a05859c2e8ce0a023a20fe2890d56d128c 100644 (file)
@@ -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
index f34b25f8c38f3b24163f384c92007e6d7a70d94e..e9f43ba2f612240ba07584cbf786e8f1f74e23ac 100644 (file)
@@ -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);
index 81326d27b42651286c7952c74dcc75e84dbd20ac..7604077d46accf14eb8f8ad0c0e3df996948ccc9 100644 (file)
@@ -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);
     }
 
 
index dfeb0f3db3bbfec159904cc078ce5f5e04bb4394..3e026cba2ecd52f75523fae42b96f230aa2953bd 100644 (file)
@@ -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);