* lock mechanism added to export
This commit is contained in:
parent
5b04f5e222
commit
b17a4c71f7
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user