mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-08-05 12:57:25 +02:00
Sends PHP packaged archives in smaller segments (16MB) to not hit PHP's memory limit. Thanks to Zaoh Lei.
This commit is contained in:
@@ -105,7 +105,7 @@ Options
|
|||||||
*/
|
*/
|
||||||
"download": {
|
"download": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"execution": "shell",
|
"execution": "php",
|
||||||
"format": "tar",
|
"format": "tar",
|
||||||
"packageName": null
|
"packageName": null
|
||||||
},
|
},
|
||||||
|
@@ -136,21 +136,18 @@ class Api {
|
|||||||
header("Connection: close");
|
header("Connection: close");
|
||||||
register_shutdown_function("delete_tempfile", $target);
|
register_shutdown_function("delete_tempfile", $target);
|
||||||
|
|
||||||
readfile($target);
|
// readfile($target);
|
||||||
|
|
||||||
// Patch by Zhao Lei
|
// Send data in small segments of 16MB to not hit PHP's memory limit (default: 128M)
|
||||||
// Max size of download file is limited by memory_limit(default: 128M)
|
if ($fd = fopen($target, 'rb')) {
|
||||||
// in php.ini if we use readfile().
|
set_time_limit(0);
|
||||||
// To solve this problem, we can change to send data with small segments.
|
while (!feof($fd)) {
|
||||||
// if ($fd = fopen($target, 'rb')) {
|
print fread($fd, 1024 * 1024 * 16);
|
||||||
// set_time_limit(0);
|
ob_flush();
|
||||||
// while (!feof($fd)) {
|
flush();
|
||||||
// print fread($fd, 1024 * 64);
|
}
|
||||||
// ob_flush();
|
fclose($fd);
|
||||||
// flush();
|
}
|
||||||
// }
|
|
||||||
// fclose($fd);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user