change logic of sending file contents to handle an off by one and be more readable

This commit is contained in:
Isaac Connor 2016-11-03 11:42:42 -04:00
parent 9d76c9cf6a
commit 6d57b326fa
1 changed files with 5 additions and 4 deletions

View File

@ -94,10 +94,11 @@ flush();
$cur = $begin; $cur = $begin;
fseek( $fh, $begin, 0 ); fseek( $fh, $begin, 0 );
while( ! feof( $fh ) && $cur < $end && ( connection_status() == 0 ) ) { while( $length && ( ! feof( $fh ) ) && ( connection_status() == 0 ) ) {
#Error("Sending $cur"); $amount = min( 1024*16, $length );
print fread( $fh, min( 1024*16, $end - $cur ) );
$cur += 1024*16; print fread( $fh, $amount );
$length -= $amount;
usleep(100); usleep(100);
} }