diff --git a/app/Import.php b/app/Import.php index 7d86e2e53..b6c821708 100644 --- a/app/Import.php +++ b/app/Import.php @@ -81,7 +81,12 @@ public function csvFiles(): Collection public function files(string $dir = null): 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)); } diff --git a/database/factories/ImportFactory.php b/database/factories/ImportFactory.php index 15c1cc3d8..8804f7f1e 100644 --- a/database/factories/ImportFactory.php +++ b/database/factories/ImportFactory.php @@ -20,6 +20,7 @@ public function definition() return [ 'name' => fake()->text(), 'class_name' => MgImporter::class, + 'dir_path' => '.', ]; } }