Hub Import Mod Removal

Removes mods that are no longer on the hub.
This commit is contained in:
Refringe 2024-10-03 16:11:26 -04:00
parent 424a329688
commit 755aad8da6
Signed by: Refringe
SSH Key Fingerprint: SHA256:t865XsQpfTeqPRBMN2G6+N8wlDjkgUCZF3WGW6O9N/k
2 changed files with 17 additions and 1 deletions

View File

@ -51,6 +51,9 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
$this->importMods();
$this->importModVersions();
// Remove mods that are no longer on the hub.
$this->removeDeletedMods();
// Ensure that we've disconnected from the Hub database, clearing temporary tables.
DB::connection('mysql_hub')->disconnect();
@ -965,6 +968,19 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
}, 'versionID');
}
/**
* Remove mods that are no longer on the Hub.
*/
private function removeDeletedMods(): void
{
$mods = Mod::select('hub_id')->all();
foreach ($mods as $mod) {
if (DB::connection('mysql_hub')->table('filebase1_file')->where('fileID', $mod->hub_id)->doesntExist()) {
$mod->delete();
}
}
}
/**
* The job failed to process.
*/

View File

@ -207,7 +207,7 @@ return [
'maxJobs' => 0,
'memory' => 256,
'tries' => 1,
'timeout' => 1500, // 25 Minutes
'timeout' => 2700, // 45 Minutes
'nice' => 0,
],
],