diff --git a/src/App/Service/GalleryService.php b/src/App/Service/GalleryService.php index 28b14ed..2dc5f8e 100644 --- a/src/App/Service/GalleryService.php +++ b/src/App/Service/GalleryService.php @@ -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; }