Created
April 16, 2009 16:24
-
-
Save mnutt/96502 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/apps/tracker/modules/torrent/actions/actions.class.php b/apps/tracker/modules/torrent/actions/actions.class.php | |
index 2997f23..fbd83ae 100644 | |
--- a/apps/tracker/modules/torrent/actions/actions.class.php | |
+++ b/apps/tracker/modules/torrent/actions/actions.class.php | |
@@ -48,8 +48,6 @@ class torrentActions extends sfActions | |
if(function_exists("apache_setenv")) // could be running under fastcgi or in non-apache env | |
apache_setenv('no-gzip', 1); | |
ini_set('zlib.output_compression', 0); | |
- ini_set('implicit_flush', 1); | |
- header('Content-type: multipart/x-mixed-replace;boundary="rn9012"'); | |
$file=new sfValidatedFileFromUrl($params['web_url'],Array($this,'progress')); | |
$is_replace=true; | |
} | |
@@ -123,17 +121,19 @@ class torrentActions extends sfActions | |
$info=$o->getInfo(); | |
- $partial = $this->getPartial('torrent/progress',Array('info'=>$info,'done'=>$done,'skipped'=>$skipped,'calls'=>$calls)); | |
+ if($info['download_content_length']) | |
+ $percent=$info['size_download']/$info['download_content_length'] *100.0; | |
+ else | |
+ $percent=0; | |
+ $percent=round($percent,2); // 2 significant digits -- ie "31.33%" | |
- if(!@$last_partial || $partial!=$last_partial) // only send the partial if something has happened | |
- { | |
- echo "--rn9012\n"; | |
- echo "Content-Type: text/html\n\n"; | |
- echo $partial; | |
- flush(); | |
- ob_flush(); | |
- $last_partial=$partial; | |
- } | |
+ $data = "{percent: '".$percent."', finished: '".$info['size_download']."', total: '".$info['download_content_length']."'}"; | |
+ | |
+ $root=sfContext::getInstance()->getConfiguration()->getRootDir(); | |
+ $path="$root/cache/progress.json"; | |
+ $fp = fopen($path, "w"); | |
+ fwrite($fp, $data); | |
+ fclose($fp); | |
$time=$now; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment