Fixes album export by reducing memory usage of the scripts.
Chunks the output buffer to 4kB chunks. This means the Download.php script will no longer run out of memory when trying to stream a tar file the output buffer.
This commit is contained in:
parent
20db3561cf
commit
9d10d53d9f
2
app.php
2
app.php
@ -27,6 +27,6 @@ set_error_handler('ErrorHandler::handleError');
|
|||||||
ini_set("display_errors", DEBUG ? "On" : "Off");
|
ini_set("display_errors", DEBUG ? "On" : "Off");
|
||||||
|
|
||||||
// The real magic starts here!
|
// The real magic starts here!
|
||||||
ob_start();
|
ob_start(null, 32768);
|
||||||
Dispatcher::dispatch();
|
Dispatcher::dispatch();
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
@ -53,20 +53,6 @@ class Download extends HTMLController
|
|||||||
{
|
{
|
||||||
$files = array();
|
$files = array();
|
||||||
|
|
||||||
$album_ids = array_merge(array($album->id_tag), $this->getChildAlbumIds($album->id_tag));
|
|
||||||
foreach($album_ids as $album_id)
|
|
||||||
{
|
|
||||||
$iterator = AssetIterator::getByOptions(
|
|
||||||
array(
|
|
||||||
'id_tag' => $album_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
while($asset = $iterator->Next())
|
|
||||||
{
|
|
||||||
$files[] = join(DIRECTORY_SEPARATOR, array('.', $asset->getSubdir(), $asset->getFilename()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
0 => array('pipe', 'r'),
|
0 => array('pipe', 'r'),
|
||||||
1 => array('pipe', 'w'),
|
1 => array('pipe', 'w'),
|
||||||
@ -93,8 +79,19 @@ class Download extends HTMLController
|
|||||||
header('Content-Type: application/octet-stream');
|
header('Content-Type: application/octet-stream');
|
||||||
header('Content-Transfer-Encoding: binary');
|
header('Content-Transfer-Encoding: binary');
|
||||||
|
|
||||||
foreach($files as $file)
|
$album_ids = array_merge(array($album->id_tag), $this->getChildAlbumIds($album->id_tag));
|
||||||
fwrite($pipes[0], $file . "\0");
|
foreach($album_ids as $album_id)
|
||||||
|
{
|
||||||
|
$iterator = AssetIterator::getByOptions(
|
||||||
|
array(
|
||||||
|
'id_tag' => $album_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
while($asset = $iterator->Next())
|
||||||
|
{
|
||||||
|
fwrite($pipes[0], join(DIRECTORY_SEPARATOR, array('.', $asset->getSubdir(), $asset->getFilename())) . "\0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fclose($pipes[0]);
|
fclose($pipes[0]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user