Skip to content

Commit

Permalink
[import] check if path exists
Browse files Browse the repository at this point in the history
  • Loading branch information
rastislav-chynoransky committed Nov 9, 2024
1 parent 1465aff commit abbe5a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
5 changes: 5 additions & 0 deletions app/ImportRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit abbe5a4

Please sign in to comment.