1
0
Fork 0

Exclude directory paths from file system search (#401)

* Exclude directories from file system search

Directories can also match the glob search pattern if their names end in ".php", which will cause a read error later since the ContentRetriever implementers are expecting files. As far as I know, the only way to fix this is to do an additional check to ensure the URI is not of a directory.

This resolves #306.
pull/405/head^2
Nicholas Narsing 2017-06-11 17:24:17 -04:00 committed by Felix Becker
parent fe7e9d5800
commit 8d1732ed02
1 changed files with 5 additions and 1 deletions

View File

@ -22,7 +22,11 @@ class FileSystemFilesFinder implements FilesFinder
return coroutine(function () use ($glob) { return coroutine(function () use ($glob) {
$uris = []; $uris = [];
foreach (new GlobIterator($glob) as $path) { foreach (new GlobIterator($glob) as $path) {
// Exclude any directories that also match the glob pattern
if (!is_dir($path)) {
$uris[] = pathToUri($path); $uris[] = pathToUri($path);
}
yield timeout(); yield timeout();
} }
return $uris; return $uris;