diff --git a/src/core/etl/src/Flow/ETL/Filesystem/FlysystemFS.php b/src/core/etl/src/Flow/ETL/Filesystem/FlysystemFS.php index 5e8f88f2b..d4aabef64 100644 --- a/src/core/etl/src/Flow/ETL/Filesystem/FlysystemFS.php +++ b/src/core/etl/src/Flow/ETL/Filesystem/FlysystemFS.php @@ -120,12 +120,10 @@ public function open(Path $path, Mode $mode) : FileStream $fs->createDirectory($path->parentDirectory()->path()); } - /** @phpstan-ignore-next-line */ - return new FileStream($path, \fopen($path->path(), $mode->value, false, $path->context()->resource())); + return new FileStream($path, \fopen($path->path(), $mode->value, false, $path->context()->resource()) ?: null); } - /** @phpstan-ignore-next-line */ - return new FileStream($path, \fopen($path->uri(), $mode->value, false, $path->context()->resource())); + return new FileStream($path, \fopen($path->uri(), $mode->value, false, $path->context()->resource()) ?: null); } public function rm(Path $path) : void @@ -180,6 +178,12 @@ public function scan(Path $path, PartitionFilter $partitionFilter) : \Generator default => throw new InvalidArgumentException('Unexpected scheme: ' . $path->scheme()) }; + if ($fs->fileExists($path->path())) { + yield $path; + + return; + } + $filter = function (FileAttributes|DirectoryAttributes $file) use ($path, $partitionFilter) : bool { if ($file instanceof DirectoryAttributes) { return false; @@ -191,23 +195,9 @@ public function scan(Path $path, PartitionFilter $partitionFilter) : \Generator } } - $filePath = new Path(DIRECTORY_SEPARATOR . $file->path()); - - if (\count($filePath->partitions())) { - if (!$partitionFilter->keep(...$filePath->partitions())) { - return false; - } - } - - return true; + return $partitionFilter->keep(...(new Path(DIRECTORY_SEPARATOR . $file->path()))->partitions()); }; - if ($fs->fileExists($path->path())) { - yield $path; - - return; - } - /** * @psalm-suppress ArgumentTypeCoercion *