Skip to content

Commit

Permalink
fix: directory file list step to handle glob returns and constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
keevan committed Jul 25, 2023
1 parent ebf33da commit 462a5e4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions classes/local/step/directory_file_list_trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,17 @@ public function run() {
$this->get_engine()->abort($error);
}

// Get the list of files.
$pathpattern = $path . DIRECTORY_SEPARATOR . $pattern;
$filelist = glob($pathpattern, GLOB_BRACE) || [];
if ($filelist !== false) {
$this->apply_list_constraints($filelist, $returnvalue, $config->sort, $offset, $limit, $includedir, $path);
$filelist = glob($pathpattern, GLOB_BRACE);
if (empty($filelist)) {
$this->log->notice("No files returned", ['pattern' => $pathpattern]);
return [];
}

// Apply constraints.
$filelist = $this->apply_list_constraints($filelist, $returnvalue, $config->sort, $offset, $limit, $includedir, $path);

return $filelist;
}

Expand Down Expand Up @@ -178,7 +183,7 @@ public function validate_for_run() {
* @param bool $includedir
* @param string $basepath
* @param string $pattern
* @return array Will return true or an array of errors.
* @return array new file list
*/
public function apply_list_constraints(
array $filelist,
Expand Down

0 comments on commit 462a5e4

Please sign in to comment.