* lock mechanism added to export

This commit is contained in:
Danyi Dávid 2017-08-15 23:05:11 +02:00
parent 5b04f5e222
commit b17a4c71f7

View File

@ -52,10 +52,16 @@ class GalleryService
if(file_exists($exportName)) {
return $exportName;
}
$exportLock = sprintf("data/tmp/%s.lock", $dir);
if(file_exists($exportLock)) {
return false;
}
$images = array_map('basename', glob($this->getImageDir($dir) . "*.{jpg,jpeg,png}", GLOB_BRACE));
$zipName = tempnam("data/tmp", "export");
touch($exportLock);
$zipArchive = new \ZipArchive();
$zipArchive->open($zipName, \ZipArchive::CREATE);
foreach ($images as $image) {
@ -67,6 +73,7 @@ class GalleryService
}
$zipArchive->close();
rename($zipName, $exportName);
unlink($exportLock);
return $exportName;
}