From 2c17c93e2f99c1f66570a3f61998b4d87e5a4a65 Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 28 Jul 2023 12:54:15 +0300 Subject: [PATCH] fix broken snaps autodelection --- crontab/cleaner.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/crontab/cleaner.php b/crontab/cleaner.php index 701d3a5..fc35fc6 100644 --- a/crontab/cleaner.php +++ b/crontab/cleaner.php @@ -272,27 +272,33 @@ try { $logsCrawlerDeleted += $db->deleteLogCrawler(time() - CRAWL_LOG_SECONDS_OFFSET); // Delete failed snaps - $snapFilePath = chunk_split($hostPage->hostPageId, 1, '/'); + foreach ($db->getHosts() as $host) { - foreach ($db->getHostPageSnaps($hostPage->hostPageId, false, false, 'AND') as $hostPageSnap) { + foreach ($db->getHostPages($host->hostId) as $hostPage) { - if ($hostPageSnap->storageLocal) { + $snapFilePath = chunk_split($hostPage->hostPageId, 1, '/'); - unlink(__DIR__ . '/../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); - } + foreach ($db->getHostPageSnaps($hostPage->hostPageId, false, false, 'AND') as $hostPageSnap) { - if ($hostPageSnap->storageMega) { + if ($hostPageSnap->storageLocal) { - $ftp = new Ftp(); + unlink(__DIR__ . '/../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); + } - if ($ftp->connect(MEGA_FTP_HOST, MEGA_FTP_PORT, null, null, MEGA_FTP_DIRECTORY)) { - $ftp->delete('hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); - } - } + if ($hostPageSnap->storageMega) { - $db->deleteHostPageSnapDownloads($hostPageSnap->hostPageSnapId); + $ftp = new Ftp(); - $hostPagesSnapDeleted += $db->deleteHostPageSnap($hostPageSnap->hostPageSnapId); + if ($ftp->connect(MEGA_FTP_HOST, MEGA_FTP_PORT, null, null, MEGA_FTP_DIRECTORY)) { + $ftp->delete('hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); + } + } + + $db->deleteHostPageSnapDownloads($hostPageSnap->hostPageSnapId); + + $hostPagesSnapDeleted += $db->deleteHostPageSnap($hostPageSnap->hostPageSnapId); + } + } } // Commit results