From 181dc108c183e97cfb7037a7f8a1542c46562d23 Mon Sep 17 00:00:00 2001 From: Dhaverd Date: Tue, 3 Jun 2025 22:36:18 +0800 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D1=83=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B8=20=D0=B4=D0=B8=D1=80?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=B8=20=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=D1=87=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F;=20=D0=94=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D1=8D=D1=82=D1=83=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B0=D0=BD=D0=B4=D1=83=20=D0=B2=20=D0=B5?= =?UTF-8?q?=D0=B6=D0=B5=D0=B4=D0=BD=D0=B5=D0=B2=D0=BD=D1=8B=D0=B9=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=83=D1=81=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/ClearDownloads.php | 42 +++++++++++++++++++++++++ app/Console/Kernel.php | 1 + 2 files changed, 43 insertions(+) create mode 100644 app/Console/Commands/ClearDownloads.php 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(); } /**