mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-01-09 06:17:52 +00:00
fix snap foreign keys deletion
This commit is contained in:
parent
242e0abd86
commit
5d7f2bf68c
@ -89,36 +89,23 @@ try {
|
|||||||
|
|
||||||
foreach ($db->getHostPageSnaps($hostPage->hostPageId) as $hostPageSnap) {
|
foreach ($db->getHostPageSnaps($hostPage->hostPageId) as $hostPageSnap) {
|
||||||
|
|
||||||
$snapFileLocalExists = (bool) $hostPageSnap->storageLocal;
|
if ($hostPageSnap->storageLocal) {
|
||||||
$snapFileMegaExists = (bool) $hostPageSnap->storageMega;
|
|
||||||
|
|
||||||
if ($snapFileLocalExists) {
|
unlink('../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip');
|
||||||
|
|
||||||
if (unlink('../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip')) {
|
|
||||||
|
|
||||||
$snapFileLocalExists = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($snapFileMegaExists) {
|
if ($hostPageSnap->storageMega) {
|
||||||
|
|
||||||
$ftp = new Ftp();
|
$ftp = new Ftp();
|
||||||
|
|
||||||
if ($ftp->connect(MEGA_FTP_HOST, MEGA_FTP_PORT, null, null, MEGA_FTP_DIRECTORY)) {
|
if ($ftp->connect(MEGA_FTP_HOST, MEGA_FTP_PORT, null, null, MEGA_FTP_DIRECTORY)) {
|
||||||
|
$ftp->delete('hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip');
|
||||||
if ($ftp->delete('hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip')) {
|
|
||||||
|
|
||||||
$snapFileMegaExists = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$snapFileLocalExists && !$snapFileMegaExists) {
|
$db->deleteHostPageSnapDownloads($hostPageSnap->hostPageSnapId);
|
||||||
|
|
||||||
$db->deleteHostPageSnapDownloads($hostPageSnap->hostPageSnapId);
|
$hostPagesSnapDeleted += $db->deleteHostPageSnap($hostPageSnap->hostPageSnapId);
|
||||||
|
|
||||||
$hostPagesSnapDeleted += $db->deleteHostPageSnap($hostPageSnap->hostPageSnapId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete host page
|
// Delete host page
|
||||||
@ -145,36 +132,23 @@ try {
|
|||||||
|
|
||||||
foreach ($db->getHostPageSnaps($hostPage->hostPageId) as $hostPageSnap) {
|
foreach ($db->getHostPageSnaps($hostPage->hostPageId) as $hostPageSnap) {
|
||||||
|
|
||||||
$snapFileLocalExists = (bool) $hostPageSnap->storageLocal;
|
if ($hostPageSnap->storageLocal) {
|
||||||
$snapFileMegaExists = (bool) $hostPageSnap->storageMega;
|
|
||||||
|
|
||||||
if ($snapFileLocalExists) {
|
unlink('../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip');
|
||||||
|
|
||||||
if (unlink('../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip')) {
|
|
||||||
|
|
||||||
$snapFileLocalExists = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($snapFileMegaExists) {
|
if ($hostPageSnap->storageMega) {
|
||||||
|
|
||||||
$ftp = new Ftp();
|
$ftp = new Ftp();
|
||||||
|
|
||||||
if ($ftp->connect(MEGA_FTP_HOST, MEGA_FTP_PORT, null, null, MEGA_FTP_DIRECTORY)) {
|
if ($ftp->connect(MEGA_FTP_HOST, MEGA_FTP_PORT, null, null, MEGA_FTP_DIRECTORY)) {
|
||||||
|
$ftp->delete('hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip');
|
||||||
if ($ftp->delete('hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip')) {
|
|
||||||
|
|
||||||
$snapFileMegaExists = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$snapFileLocalExists && !$snapFileMegaExists) {
|
$db->deleteHostPageSnapDownloads($hostPageSnap->hostPageSnapId);
|
||||||
|
|
||||||
$db->deleteHostPageSnapDownloads($hostPageSnap->hostPageSnapId);
|
$hostPagesSnapDeleted += $db->deleteHostPageSnap($hostPageSnap->hostPageSnapId);
|
||||||
|
|
||||||
$hostPagesSnapDeleted += $db->deleteHostPageSnap($hostPageSnap->hostPageSnapId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete host page
|
// Delete host page
|
||||||
|
Loading…
Reference in New Issue
Block a user