--- lib/PXElator/httpd.pm 2009/08/01 00:44:52 107 +++ lib/PXElator/httpd.pm 2009/08/02 12:09:02 115 @@ -38,8 +38,7 @@ use html; our $static_pids; - -use Time::HiRes qw/time/; +use progress_bar; sub static { my ($client,$path) = @_; @@ -71,26 +70,15 @@ my $buff; my $pos = 0; - STDERR->autoflush(1); warn "static $path $type $size block: $block\n"; - my $start_t = time(); - my $last_t = $start_t; + progress_bar::start; while( my $len = read $fh, $buff, $block ) { print $client $buff; $client->flush; $pos += $len; - my $t = time(); - next unless $t - $last_t > 0.75; - $last_t = $t; - my $speed = ( $pos ) / ( $t - $start_t ); - printf STDERR "%s %d/%d %.2f%% %.2f K/s ETA %.1fs \r" - , $path, $pos - , $size, $pos * 100 / $size - , $speed / 1024 - , ( $size - $pos ) / $speed - ; + progress_bar::tick( $path, $pos, $size ); } close($fh); close($client);