mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-02-03 10:25:52 +00:00
autodelete failed snaps
This commit is contained in:
parent
4298203cab
commit
443eaec64e
@ -271,6 +271,30 @@ try {
|
||||
$logsCleanerDeleted += $db->deleteLogCleaner(time() - CLEAN_LOG_SECONDS_OFFSET);
|
||||
$logsCrawlerDeleted += $db->deleteLogCrawler(time() - CRAWL_LOG_SECONDS_OFFSET);
|
||||
|
||||
// Delete failed snaps
|
||||
$snapFilePath = chunk_split($hostPage->hostPageId, 1, '/');
|
||||
|
||||
foreach ($db->getHostPageSnaps($hostPage->hostPageId, false, false, 'AND') as $hostPageSnap) {
|
||||
|
||||
if ($hostPageSnap->storageLocal) {
|
||||
|
||||
unlink(__DIR__ . '/../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip');
|
||||
}
|
||||
|
||||
if ($hostPageSnap->storageMega) {
|
||||
|
||||
$ftp = new Ftp();
|
||||
|
||||
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
|
||||
$db->commit();
|
||||
|
||||
|
@ -417,9 +417,9 @@ class MySQL {
|
||||
return $query->fetch()->total;
|
||||
}
|
||||
|
||||
public function getHostPageSnaps(int $hostPageId, bool $storageLocal = true, bool $storageMega = true) {
|
||||
public function getHostPageSnaps(int $hostPageId, bool $storageLocal = true, bool $storageMega = true, string $condition = 'OR') {
|
||||
|
||||
$query = $this->_db->prepare('SELECT * FROM `hostPageSnap` WHERE `hostPageId` = ? AND (`storageLocal` = ? OR `storageMega` = ?) ORDER BY `timeAdded` DESC');
|
||||
$query = $this->_db->prepare('SELECT * FROM `hostPageSnap` WHERE `hostPageId` = ? AND (`storageLocal` = ? ' . ($condition == 'OR' ? 'OR' : 'AND') . ' `storageMega` = ?) ORDER BY `timeAdded` DESC');
|
||||
|
||||
$query->execute([$hostPageId, $storageLocal, $storageMega]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user