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:
2
app.php
2
app.php
@@ -27,6 +27,6 @@ set_error_handler('ErrorHandler::handleError');
|
||||
ini_set("display_errors", DEBUG ? "On" : "Off");
|
||||
|
||||
// The real magic starts here!
|
||||
ob_start();
|
||||
ob_start(null, 32768);
|
||||
Dispatcher::dispatch();
|
||||
ob_end_flush();
|
||||
|
||||
@@ -53,20 +53,6 @@ class Download extends HTMLController
|
||||
{
|
||||
$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(
|
||||
0 => array('pipe', 'r'),
|
||||
1 => array('pipe', 'w'),
|
||||
@@ -93,8 +79,19 @@ class Download extends HTMLController
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
foreach($files as $file)
|
||||
fwrite($pipes[0], $file . "\0");
|
||||
$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())
|
||||
{
|
||||
fwrite($pipes[0], join(DIRECTORY_SEPARATOR, array('.', $asset->getSubdir(), $asset->getFilename())) . "\0");
|
||||
}
|
||||
}
|
||||
|
||||
fclose($pipes[0]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user