diff --git a/app/Console/Commands/ClearDownloads.php b/app/Console/Commands/ClearDownloads.php new file mode 100644 index 0000000..0071796 --- /dev/null +++ b/app/Console/Commands/ClearDownloads.php @@ -0,0 +1,42 @@ +info("Clearing download directory: " . env('PATH_TO_DOWNLOAD')); + $directory = new Filesystem(); + $files = $directory->files(env('PATH_TO_DOWNLOAD'), false); + $counter = 0; + foreach ($files as $file){ + if ($file->getFilename() !== '.gitignore'){ + $this->info("rm " . $file->getRealPath()); + unlink($file->getRealPath()); + $counter++; + } + } + $this->info("Deleted " . $counter . " file(s)"); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e6b9960..3214845 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,6 +13,7 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule): void { // $schedule->command('inspire')->hourly(); + $schedule->command('app:clear-downloads')->daily(); } /**