return false early from directory resource
This commit is contained in:
parent
f7ba71db7c
commit
96107e21f1
@ -68,7 +68,10 @@ class DirectoryResource implements ResourceInterface, \Serializable
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$newestMTime = filemtime($this->resource);
|
if ($timestamp <= filemtime($this->resource)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
|
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
|
||||||
// if regex filtering is enabled only check matching files
|
// if regex filtering is enabled only check matching files
|
||||||
if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
|
if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
|
||||||
@ -81,10 +84,13 @@ class DirectoryResource implements ResourceInterface, \Serializable
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$newestMTime = max($file->getMTime(), $newestMTime);
|
// early return if a file's mtime exceeds the passed timestamp
|
||||||
|
if ($timestamp <= $file->getMTime()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $newestMTime < $timestamp;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serialize()
|
public function serialize()
|
||||||
|
Reference in New Issue
Block a user