Add S3 clean up on hosted

This commit is contained in:
David Bomba 2021-09-08 14:14:46 +10:00
parent 1fb6030bc8
commit 4d35ed3ce5
2 changed files with 8 additions and 3 deletions

View File

@ -20,7 +20,7 @@ class S3Cleanup extends Command
*
* @var string
*/
protected $description = 'Remove orphan folders';
protected $description = 'Remove orphan folders/files';
/**
* Create a new command instance.
@ -54,7 +54,11 @@ class S3Cleanup extends Command
if(!in_array($dir, $merged))
{
$this->logMessage("Deleting $dir");
Storage::disk(config('filesystems.default'))->deleteDirectory($dir);
/* Ensure we are not deleting the root folder */
if(strlen($dir) > 1)
Storage::disk(config('filesystems.default'))->deleteDirectory($dir);
}
}

View File

@ -71,7 +71,8 @@ class Kernel extends ConsoleKernel
$schedule->job(new AdjustEmailQuota)->dailyAt('23:00')->withoutOverlapping();
$schedule->job(new SendFailedEmails)->daily()->withoutOverlapping();
$schedule->command('ninja:check-data --database=db-ninja-02')->daily()->withoutOverlapping();
$schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('00:15')->withoutOverlapping();
$schedule->command('ninja:s3-cleanup')->dailyAt('23:15')->withoutOverlapping();
}