Image sync method fixes
gitea/hedera-web/pipeline/head This commit looks good
Details
gitea/hedera-web/pipeline/head This commit looks good
Details
This commit is contained in:
parent
6c59b72023
commit
079e9266f1
|
@ -1,4 +1,4 @@
|
||||||
hedera-web (1.407.27) stable; urgency=low
|
hedera-web (1.407.28) stable; urgency=low
|
||||||
|
|
||||||
* Initial Release.
|
* Initial Release.
|
||||||
|
|
||||||
|
|
|
@ -5,4 +5,5 @@ MAILTO=webmaster
|
||||||
0 23 * * * root hedera-web.php -m edi/clean
|
0 23 * * * root hedera-web.php -m edi/clean
|
||||||
0 5 * * * root hedera-web.php -m edi/update
|
0 5 * * * root hedera-web.php -m edi/update
|
||||||
0 5 * * * root hedera-web.php -m misc/exchange-rate
|
0 5 * * * root hedera-web.php -m misc/exchange-rate
|
||||||
|
0 0 * * * root hedera-web.php -m image/sync
|
||||||
0 */1 * * * root /usr/share/hedera-web/utils/update-browscap.sh > /dev/null
|
0 */1 * * * root /usr/share/hedera-web/utils/update-browscap.sh > /dev/null
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hedera-web",
|
"name": "hedera-web",
|
||||||
"version": "1.407.27",
|
"version": "1.407.28",
|
||||||
"description": "Verdnatura web page",
|
"description": "Verdnatura web page",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -49,22 +49,36 @@ class Sync extends Vn\Lib\Method {
|
||||||
|
|
||||||
// Deletes unreferenced images.
|
// Deletes unreferenced images.
|
||||||
|
|
||||||
$res = $db->query(
|
try {
|
||||||
'SELECT `name`, collectionFk
|
$db->query('START TRANSACTION');
|
||||||
FROM `image`
|
$res = $db->query(
|
||||||
WHERE nRefs = 0 AND collectionFk = #collection',
|
'SELECT id, `name`, collectionFk
|
||||||
['collection' => $collection]
|
FROM `image`
|
||||||
);
|
WHERE nRefs = 0 AND collectionFk = #collection
|
||||||
|
FOR UPDATE',
|
||||||
|
['collection' => $collection]
|
||||||
|
);
|
||||||
|
|
||||||
while ($image = $res->fetch_object()) {
|
while ($image = $res->fetch_object())
|
||||||
$deleteCount++;
|
if (!empty($image) && !in_array($image->name, ['.', '..'])) {
|
||||||
$this->recycle("$collection/full/{$image->name}.png");
|
$deleteCount++;
|
||||||
|
$this->recycle("$collection/full/{$image->name}.png");
|
||||||
|
|
||||||
foreach ($info['sizes'] as $size => $i)
|
foreach ($info['sizes'] as $size => $i)
|
||||||
$this->recycle("$collection/$size/{$image->name}.png");
|
$this->recycle("$collection/$size/{$image->name}.png");
|
||||||
|
|
||||||
|
$db->query(
|
||||||
|
'DELETE FROM `image`
|
||||||
|
WHERE nRefs = 0 AND id = #id',
|
||||||
|
['id' => $image->id]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$res->free();
|
||||||
|
$db->query('COMMIT');
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$db->query('ROLLBACK');
|
||||||
}
|
}
|
||||||
|
|
||||||
$res->free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Syncronization finished. $deleteCount images moved to trash.\n";
|
echo "Syncronization finished. $deleteCount images moved to trash.\n";
|
||||||
|
|
Loading…
Reference in New Issue