* lock mechanism added to export
This commit is contained in:
parent
5b04f5e222
commit
b17a4c71f7
@ -52,10 +52,16 @@ class GalleryService
|
|||||||
if(file_exists($exportName)) {
|
if(file_exists($exportName)) {
|
||||||
return $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));
|
$images = array_map('basename', glob($this->getImageDir($dir) . "*.{jpg,jpeg,png}", GLOB_BRACE));
|
||||||
|
|
||||||
$zipName = tempnam("data/tmp", "export");
|
$zipName = tempnam("data/tmp", "export");
|
||||||
|
touch($exportLock);
|
||||||
$zipArchive = new \ZipArchive();
|
$zipArchive = new \ZipArchive();
|
||||||
$zipArchive->open($zipName, \ZipArchive::CREATE);
|
$zipArchive->open($zipName, \ZipArchive::CREATE);
|
||||||
foreach ($images as $image) {
|
foreach ($images as $image) {
|
||||||
@ -67,6 +73,7 @@ class GalleryService
|
|||||||
}
|
}
|
||||||
$zipArchive->close();
|
$zipArchive->close();
|
||||||
rename($zipName, $exportName);
|
rename($zipName, $exportName);
|
||||||
|
unlink($exportLock);
|
||||||
return $exportName;
|
return $exportName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user