diff options
Diffstat (limited to 'app/Services/AdminService.php')
| -rw-r--r-- | app/Services/AdminService.php | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/app/Services/AdminService.php b/app/Services/AdminService.php index 40c50819ed..ec0f048dcd 100644 --- a/app/Services/AdminService.php +++ b/app/Services/AdminService.php @@ -34,7 +34,9 @@ use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; -use League\Flysystem\FilesystemInterface; +use League\Flysystem\FilesystemException; +use League\Flysystem\FilesystemOperator; +use League\Flysystem\StorageAttributes; use function array_map; use function explode; @@ -240,29 +242,32 @@ class AdminService /** * A list of GEDCOM files in the data folder. * - * @param FilesystemInterface $filesystem + * @param FilesystemOperator $filesystem * * @return Collection<string> + * @throws FilesystemException */ - public function gedcomFiles(FilesystemInterface $filesystem): Collection + public function gedcomFiles(FilesystemOperator $filesystem): Collection { - return Collection::make($filesystem->listContents()) - ->filter(static function (array $path) use ($filesystem): bool { - if ($path['type'] !== 'file') { + $files = $filesystem->listContents('') + ->filter(static function (StorageAttributes $attributes) use ($filesystem) { + if (!$attributes->isFile()) { return false; } - $stream = $filesystem->readStream($path['path']); + $stream = $filesystem->readStream($attributes->path()); $header = fread($stream, 10); fclose($stream); return preg_match('/^(' . Gedcom::UTF8_BOM . ')?0 HEAD/', $header) > 0; }) - ->map(static function (array $path): string { - return $path['path']; + ->map(function (StorageAttributes $attributes) { + return $attributes->path(); }) - ->sort(); + ->toArray(); + + return Collection::make($files)->sort(); } /** |
