Rework album/tag downloads #19
@ -22,7 +22,7 @@ class Download
|
||||
$album = Tag::fromId($tag);
|
||||
|
||||
if (isset($_SESSION['current_export']))
|
||||
|
||||
throw new UserFacingException('An export of "' . $tag->tag . '" is ongoing. Please try again later.');
|
||||
throw new UserFacingException('You can only export one album at the same time. Please wait until the other download finishes, or try again later.');
|
||||
|
||||
// So far so good?
|
||||
$this->exportAlbum($album);
|
||||
@ -46,6 +46,15 @@ class Download
|
||||
1 => ['pipe', 'w'], // STDOUT
|
||||
];
|
||||
|
||||
// Prevent simultaneous exports.
|
||||
$_SESSION['current_export'] = $album->id_tag;
|
||||
|
||||
// Allow new exports if the connection is terminated unexpectedly (e.g. when a user aborts a download).
|
||||
register_shutdown_function(function() {
|
||||
if (isset($_SESSION['current_export']))
|
||||
unset($_SESSION['current_export']);
|
||||
});
|
||||
|
||||
$command = 'tar -cf - -C ' . escapeshellarg(ASSETSDIR) . ' --null -T -';
|
||||
|
||||
$proc = proc_open($command, $descriptorspec, $pipes, ASSETSDIR);
|
||||
@ -92,6 +101,9 @@ class Download
|
||||
fclose($pipes[1]);
|
||||
|
||||
proc_close($proc);
|
||||
|
||||
// Allow new exports from this point onward.
|
||||
unset($_SESSION['current_export']);
|
||||
}
|
||||
|
||||
private function getChildAlbumIds($parent_id)
|
||||
|
Loading…
Reference in New Issue
Block a user
Ik zie deze check, maar ik zie niet waar deze session variable geset word? Of mis ik iets.
Oef, terecht. Ik vermoed dat ik die ben verloren in een overijverige rebase. Gaan we fixen.