Browse Source

delete snaps from registry when not found in the any of storage available

main
ghost 1 year ago
parent
commit
30a81ca6fb
  1. 31
      cli/yggo.php

31
cli/yggo.php

@ -62,8 +62,6 @@ switch ($argv[1]) {
// Scan for new files/storages // Scan for new files/storages
CLI::notice(_('scan database registry for missed snap files...')); CLI::notice(_('scan database registry for missed snap files...'));
$hostPageSnapsTrashQueue = [];
foreach ($db->getHosts() as $host) { foreach ($db->getHosts() as $host) {
foreach ($db->getHostPages($host->hostId) as $hostPage) { foreach ($db->getHostPages($host->hostId) as $hostPage) {
@ -107,6 +105,7 @@ switch ($argv[1]) {
} }
break; break;
case 'ftp': case 'ftp':
$ftp = new Ftp(); $ftp = new Ftp();
@ -139,30 +138,14 @@ switch ($argv[1]) {
} }
} }
// Snap FS relation does not exist, add registry item to the delete queue // Files not exists
if (!$snapFilesExists) { if (!$snapFilesExists) {
$hostPageSnapsTrashQueue[] = $hostPageSnap->hostPageSnapId; // Delete snap from registry
CLI::danger(sprintf(_('trash snap index: #%s file: %s not found in the any of storage;'), $hostPageSnap->hostPageSnapId, $filename));
}
}
}
}
if ($hostPageSnapsTrashQueue && isset($argv[3]) && $argv[3] == 'purge') {
CLI::notice(_('snap index deletion queue begin...'));
foreach ($hostPageSnapsTrashQueue as $hostPageSnapId) {
try { try {
$db->beginTransaction(); $db->beginTransaction();
CLI::warning(sprintf(_('delete snap index: #%s;'), $hostPageSnapId));
// Clear queued snap registry
foreach ($db->getHostPageSnapStorages($hostPageSnapId) as $hostPageSnapStorage) { foreach ($db->getHostPageSnapStorages($hostPageSnapId) as $hostPageSnapStorage) {
$db->deleteHostPageSnapDownloads($hostPageSnapStorage->hostPageSnapStorageId); $db->deleteHostPageSnapDownloads($hostPageSnapStorage->hostPageSnapStorageId);
@ -171,6 +154,8 @@ switch ($argv[1]) {
$db->deleteHostPageSnapStorages($hostPageSnapId); $db->deleteHostPageSnapStorages($hostPageSnapId);
$db->deleteHostPageSnap($hostPageSnapId); $db->deleteHostPageSnap($hostPageSnapId);
CLI::danger(sprintf(_('delete snap index: #%s file: %s not found in the any of storage;'), $hostPageSnap->hostPageSnapId, $filename));
$db->commit(); $db->commit();
} catch(Exception $e) { } catch(Exception $e) {
@ -180,8 +165,8 @@ switch ($argv[1]) {
var_dump($e); var_dump($e);
} }
} }
}
CLI::success(_('snap index trash queue deleted!')); }
} }
CLI::notice(_('optimize database tables...')); CLI::notice(_('optimize database tables...'));
@ -359,7 +344,7 @@ CLI::default('available options:');
CLI::default(' help - this message'); CLI::default(' help - this message');
CLI::default(' crawl - execute crawler step in the crontab queue'); CLI::default(' crawl - execute crawler step in the crontab queue');
CLI::default(' clean - execute cleaner step in the crontab queue'); CLI::default(' clean - execute cleaner step in the crontab queue');
CLI::default(' snap reindex [purge] - sync DB/FS relations. optionally delete unrelated DB/FS items'); CLI::default(' snap reindex - sync DB/FS relations');
CLI::default(' hostPage rank reindex - generate rank indexes in hostPage table'); CLI::default(' hostPage rank reindex - generate rank indexes in hostPage table');
CLI::default(' hostPageDom generate [selectors] - make hostPageDom index based on related hostPage.data field'); CLI::default(' hostPageDom generate [selectors] - make hostPageDom index based on related hostPage.data field');
CLI::default(' hostPageDom truncate - flush hostPageDom table'); CLI::default(' hostPageDom truncate - flush hostPageDom table');

Loading…
Cancel
Save