1
0
Fork 0

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/401/head
Nicholas Narsing 2017-06-11 16:57:27 -04:00
parent fe7e9d5800
commit 93b5f5d209
No known key found for this signature in database
GPG Key ID: 6C867A2AC16B645A
2 changed files with 7 additions and 2 deletions

View File

@ -39,7 +39,8 @@ class ClientFilesFinder implements FilesFinder
$uris = [];
foreach ($textDocuments as $textDocument) {
$path = Uri\parse($textDocument->uri)['path'];
if (Glob::match($path, $glob)) {
// Also exclude any directories that also match the glob pattern
if (Glob::match($path, $glob) && !is_dir($path)) {
$uris[] = $textDocument->uri;
}
}

View File

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