// iterate over its length, send 8k at a time
while(!feof($localfile)) {
// read and send data
- $data = fread($localfile, 8192);
+ $data = fread($localfile, 32768);
echo $data;
// flush so the client sees the data
// TODO: this is the function im working on
// the alternative to this function is that if a file is in the process of being
// downloaded, we simply serve from upstream... not a good idea tho unless we create
- // a local proxy right here
+ // a local proxy right here - this function is a race condition waiting to be had
+ // lets hope its a good one!
function downloadAndServe($filename, $repoid, $remoteurl)
{
// this is where the fun starts - but this one isnt too bad.
error_log("OTHERDOWNLOAD: im another downloader, please work");
- $fsize = file_get_contents("$filename.size");
+ if(file_exists("$filename.size")) $fsize = file_get_contents("$filename.size");
+ else $fsize = filesize($filename);
header("Content-Length: $fsize");
$sgotten = 0;
while(!feof($localfile)) {