From 9ef2accf5134efe83e7a9827472502ac9a4ff19b Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Fri, 9 Dec 2022 13:03:38 +0000 Subject: [PATCH 1/2] Added fix to ensure that getAvailablePaths respects the maxDepth of the file iterator --- src/Halcyon/Datasource/FileDatasource.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Halcyon/Datasource/FileDatasource.php b/src/Halcyon/Datasource/FileDatasource.php index b8cd59278..9c7300128 100644 --- a/src/Halcyon/Datasource/FileDatasource.php +++ b/src/Halcyon/Datasource/FileDatasource.php @@ -34,6 +34,13 @@ class FileDatasource extends Datasource */ protected $resolvedBasePaths = []; + /** + * The maximum depth of the filesystem to scan, defaulting to 1 subdirectory. + * + * @var int + */ + protected int $maxDepth = 1; + /** * Create a new datasource instance. * @@ -98,7 +105,7 @@ public function select(string $dirName, array $options = []): array } $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath)); - $it->setMaxDepth(1); // Support only a single level of subdirectories + $it->setMaxDepth($this->maxDepth); $it->rewind(); while ($it->valid()) { @@ -337,6 +344,10 @@ public function getAvailablePaths(): array ? new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->basePath)) : []; + if (!is_array($it)) { + $it->setMaxDepth($this->maxDepth + 1); + } + foreach ($it as $file) { if ($file->isDir()) { continue; From 185fbcf9778bbf41e5ddd783cafb6ccbba4486ba Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Fri, 9 Dec 2022 15:11:58 -0600 Subject: [PATCH 2/2] Update src/Halcyon/Datasource/FileDatasource.php --- src/Halcyon/Datasource/FileDatasource.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Halcyon/Datasource/FileDatasource.php b/src/Halcyon/Datasource/FileDatasource.php index 9c7300128..014ecfec4 100644 --- a/src/Halcyon/Datasource/FileDatasource.php +++ b/src/Halcyon/Datasource/FileDatasource.php @@ -36,8 +36,6 @@ class FileDatasource extends Datasource /** * The maximum depth of the filesystem to scan, defaulting to 1 subdirectory. - * - * @var int */ protected int $maxDepth = 1;