From b17a4c71f7401805f035e18f0d3ccce9c00f59e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danyi=20D=C3=A1vid?= Date: Tue, 15 Aug 2017 23:05:11 +0200 Subject: [PATCH] * lock mechanism added to export --- src/App/Service/GalleryService.php | 7 +++++++ 1 file changed, 7 insertions(+) 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; }