[add] lock for prevent multi generation of same url
This commit is contained in:
parent
d45aa32900
commit
79457ee9c3
2 changed files with 19 additions and 10 deletions
|
@ -109,6 +109,7 @@ case $renderType in
|
|||
echo 0
|
||||
fi
|
||||
rm "../cache/tmp/$hashUrl.png"
|
||||
rm "../cache/tmp/$hashUrl.lock"
|
||||
;;
|
||||
# thumbnail + complete
|
||||
tc)
|
||||
|
@ -125,6 +126,7 @@ case $renderType in
|
|||
else
|
||||
echo 0
|
||||
fi
|
||||
rm "../cache/tmp/$hashUrl.lock"
|
||||
;;
|
||||
# thumbnail + realsize
|
||||
tr)
|
||||
|
@ -142,6 +144,7 @@ case $renderType in
|
|||
else
|
||||
echo 0
|
||||
fi
|
||||
rm "../cache/tmp/$hashUrl.lock"
|
||||
;;
|
||||
# thumbnail + realsize + complete
|
||||
trc)
|
||||
|
@ -162,6 +165,7 @@ case $renderType in
|
|||
echo 0
|
||||
fi
|
||||
rm "../cache/tmp/$hashUrl.png"
|
||||
rm "../cache/tmp/$hashUrl.lock"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
@ -151,6 +151,8 @@ function launchScript($url, $hashUrl, $width, $size, $waitForResult = false) {
|
|||
$renderType = 't';
|
||||
}
|
||||
if ($GLOBALS['config']['disableExec'] === false) {
|
||||
if (!file_exists('../cache/tmp/'.$hashUrl.'.lock')) {
|
||||
touch('../cache/tmp/'.$hashUrl.'.lock');
|
||||
chdir('bin/');
|
||||
if ($waitForResult === false) {
|
||||
exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$renderType.' > /dev/null &', $result);
|
||||
|
@ -158,6 +160,9 @@ function launchScript($url, $hashUrl, $width, $size, $waitForResult = false) {
|
|||
exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$renderType.' 1', $result);
|
||||
}
|
||||
chdir('../');
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
makeQueueFile($url, $hashUrl, $width, $size, $renderType);
|
||||
$result = 0;
|
||||
|
|
Loading…
Reference in a new issue