[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
|
echo 0
|
||||||
fi
|
fi
|
||||||
rm "../cache/tmp/$hashUrl.png"
|
rm "../cache/tmp/$hashUrl.png"
|
||||||
|
rm "../cache/tmp/$hashUrl.lock"
|
||||||
;;
|
;;
|
||||||
# thumbnail + complete
|
# thumbnail + complete
|
||||||
tc)
|
tc)
|
||||||
|
@ -125,6 +126,7 @@ case $renderType in
|
||||||
else
|
else
|
||||||
echo 0
|
echo 0
|
||||||
fi
|
fi
|
||||||
|
rm "../cache/tmp/$hashUrl.lock"
|
||||||
;;
|
;;
|
||||||
# thumbnail + realsize
|
# thumbnail + realsize
|
||||||
tr)
|
tr)
|
||||||
|
@ -142,6 +144,7 @@ case $renderType in
|
||||||
else
|
else
|
||||||
echo 0
|
echo 0
|
||||||
fi
|
fi
|
||||||
|
rm "../cache/tmp/$hashUrl.lock"
|
||||||
;;
|
;;
|
||||||
# thumbnail + realsize + complete
|
# thumbnail + realsize + complete
|
||||||
trc)
|
trc)
|
||||||
|
@ -162,6 +165,7 @@ case $renderType in
|
||||||
echo 0
|
echo 0
|
||||||
fi
|
fi
|
||||||
rm "../cache/tmp/$hashUrl.png"
|
rm "../cache/tmp/$hashUrl.png"
|
||||||
|
rm "../cache/tmp/$hashUrl.lock"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,8 @@ function launchScript($url, $hashUrl, $width, $size, $waitForResult = false) {
|
||||||
$renderType = 't';
|
$renderType = 't';
|
||||||
}
|
}
|
||||||
if ($GLOBALS['config']['disableExec'] === false) {
|
if ($GLOBALS['config']['disableExec'] === false) {
|
||||||
|
if (!file_exists('../cache/tmp/'.$hashUrl.'.lock')) {
|
||||||
|
touch('../cache/tmp/'.$hashUrl.'.lock');
|
||||||
chdir('bin/');
|
chdir('bin/');
|
||||||
if ($waitForResult === false) {
|
if ($waitForResult === false) {
|
||||||
exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$renderType.' > /dev/null &', $result);
|
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);
|
exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$renderType.' 1', $result);
|
||||||
}
|
}
|
||||||
chdir('../');
|
chdir('../');
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
makeQueueFile($url, $hashUrl, $width, $size, $renderType);
|
makeQueueFile($url, $hashUrl, $width, $size, $renderType);
|
||||||
$result = 0;
|
$result = 0;
|
||||||
|
@ -328,7 +333,7 @@ function removeOlderThan($dir = 'cache/img/shortLive') {
|
||||||
|
|
||||||
function pathForFile($size, $hashUrl) {
|
function pathForFile($size, $hashUrl) {
|
||||||
$startPath = substr($hashUrl, 0, 2).'/'.substr($hashUrl, 2, 2).'/';
|
$startPath = substr($hashUrl, 0, 2).'/'.substr($hashUrl, 2, 2).'/';
|
||||||
if(empty($size)){
|
if (empty($size)) {
|
||||||
$size = tryDetectSize($startPath.$hashUrl);
|
$size = tryDetectSize($startPath.$hashUrl);
|
||||||
}
|
}
|
||||||
$file = 'cache/img/'.$size.'/'.$startPath.$hashUrl;
|
$file = 'cache/img/'.$size.'/'.$startPath.$hashUrl;
|
||||||
|
|
Loading…
Reference in a new issue