Browse Source

cover snap deletion in transaction

main
ghost 1 year ago
parent
commit
1e664ba4cd
  1. 22
      cli/yggo.php

22
cli/yggo.php

@ -71,7 +71,7 @@ switch ($argv[1]) {
foreach ($db->getHostPageSnaps($hostPage->hostPageId) as $hostPageSnap) { foreach ($db->getHostPageSnaps($hostPage->hostPageId) as $hostPageSnap) {
// Define variables // Define variables
$snapFileExists = false; $snapFilesExists = false;
$snapPath = chunk_split($hostPage->hostPageId, 1, '/'); $snapPath = chunk_split($hostPage->hostPageId, 1, '/');
@ -91,7 +91,7 @@ switch ($argv[1]) {
if (file_exists($filename)) { if (file_exists($filename)) {
$snapFileExists = true; $snapFilesExists = true;
if (!$db->getHostPageSnapStorageByCRC32Name($hostPageSnap->hostPageSnapId, $crc32name)) { if (!$db->getHostPageSnapStorageByCRC32Name($hostPageSnap->hostPageSnapId, $crc32name)) {
@ -117,7 +117,7 @@ switch ($argv[1]) {
if ($ftp->size($filename)) { if ($ftp->size($filename)) {
$snapFileExists = true; $snapFilesExists = true;
if (!$db->getHostPageSnapStorageByCRC32Name($hostPageSnap->hostPageSnapId, $crc32name)) { if (!$db->getHostPageSnapStorageByCRC32Name($hostPageSnap->hostPageSnapId, $crc32name)) {
@ -139,7 +139,8 @@ switch ($argv[1]) {
} }
} }
if (!$snapFileExists) { // Snap FS relation does not exist, add registry item to the delete queue
if (!$snapFilesExists) {
$hostPageSnapsTrashQueue[] = $hostPageSnap->hostPageSnapId; $hostPageSnapsTrashQueue[] = $hostPageSnap->hostPageSnapId;
@ -155,6 +156,10 @@ switch ($argv[1]) {
foreach ($hostPageSnapsTrashQueue as $hostPageSnapId) { foreach ($hostPageSnapsTrashQueue as $hostPageSnapId) {
try {
$db->beginTransaction();
CLI::warning(sprintf(_('delete snap index: #%s;'), $hostPageSnapId)); CLI::warning(sprintf(_('delete snap index: #%s;'), $hostPageSnapId));
// Clear queued snap registry // Clear queued snap registry
@ -165,6 +170,15 @@ switch ($argv[1]) {
$db->deleteHostPageSnapStorages($hostPageSnapId); $db->deleteHostPageSnapStorages($hostPageSnapId);
$db->deleteHostPageSnap($hostPageSnapId); $db->deleteHostPageSnap($hostPageSnapId);
$db->commit();
} catch(Exception $e) {
$db->rollBack();
var_dump($e);
}
} }
CLI::success(_('snap index trash queue deleted!')); CLI::success(_('snap index trash queue deleted!'));

Loading…
Cancel
Save