diff --git a/app/Import.php b/app/Import.php index 7d86e2e53..3eb39aaf7 100644 --- a/app/Import.php +++ b/app/Import.php @@ -79,9 +79,14 @@ public function csvFiles(): Collection return $this->files()->filter(fn(SplFileInfo $file) => $file->getExtension() === 'csv'); } - public function files(string $dir = null): Collection + public function files(string $dir = ''): Collection { - $files = $this->storage()->files($dir ?? $this->dir_path); + $dir ??= $this->dir_path; + if (!$this->storage()->exists($dir)) { + return collect(); + } + + $files = $this->storage()->files($dir); return collect($files)->map(fn(string $file) => new SplFileInfo($file)); } diff --git a/app/ImportRecord.php b/app/ImportRecord.php index fa9df879c..ddd753c87 100644 --- a/app/ImportRecord.php +++ b/app/ImportRecord.php @@ -56,6 +56,11 @@ public function iipFiles(): Collection pathinfo($this->filename, PATHINFO_FILENAME) ); $disk = config('import.iip_disk'); + + if (!Storage::disk($disk)->exists($dir)) { + return collect(); + } + $files = Storage::disk($disk)->files($dir); return collect($files)->map(fn(string $file) => new SplFileInfo($file)); }