diff --git a/app/Console/Commands/StorageHealthCheck.php b/app/Console/Commands/StorageHealthCheck.php index b16d00f..916feb4 100644 --- a/app/Console/Commands/StorageHealthCheck.php +++ b/app/Console/Commands/StorageHealthCheck.php @@ -8,7 +8,9 @@ use Throwable; class StorageHealthCheck extends Command { - protected $signature = 'storage:health-check {disk? : Disk name, defaults to filesystems.default}'; + protected $signature = 'storage:health-check + {disk? : Disk name, defaults to filesystems.default} + {--keep : Keep the test file so the public URL can be checked in a browser}'; protected $description = 'Check current storage disk, write/read/delete a test file, and print its public URL.'; @@ -37,8 +39,13 @@ class StorageHealthCheck extends Command $this->line('exists=' . ($exists ? 'yes' : 'no')); $this->line('public_url=' . Storage::disk($disk)->url($path)); - Storage::disk($disk)->delete($path); - $this->line('delete=ok'); + if ($this->option('keep')) { + $this->warn('delete=skipped'); + $this->warn('Open public_url in browser or curl it from outside the container.'); + } else { + Storage::disk($disk)->delete($path); + $this->line('delete=ok'); + } } catch (Throwable $e) { $this->error(get_class($e) . ': ' . $e->getMessage()); return self::FAILURE;