[Config] added existence check to some resource methods
* fixed DELETED event when starting to watch a file that does not exist yet * fixed files that are deleted and then re-created Conflicts: src/Symfony/Component/ResourceWatcher/StateChecker/ResourceStateChecker.php tests/Symfony/Tests/Component/ResourceWatcher/StateChecker/DirectoryStateCheckerTest.php tests/Symfony/Tests/Component/ResourceWatcher/StateChecker/FileStateCheckerTest.php
This commit is contained in:
parent
56b60c8d46
commit
241aa92cc5
@ -75,6 +75,10 @@ class DirectoryResource implements ResourceInterface
|
|||||||
*/
|
*/
|
||||||
public function getFilteredResources()
|
public function getFilteredResources()
|
||||||
{
|
{
|
||||||
|
if (!$this->exists()) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$iterator = new \DirectoryIterator($this->resource);
|
$iterator = new \DirectoryIterator($this->resource);
|
||||||
|
|
||||||
$resources = array();
|
$resources = array();
|
||||||
@ -166,6 +170,10 @@ class DirectoryResource implements ResourceInterface
|
|||||||
*/
|
*/
|
||||||
public function getModificationTime()
|
public function getModificationTime()
|
||||||
{
|
{
|
||||||
|
if (!$this->exists()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
clearstatcache(true, $this->resource);
|
clearstatcache(true, $this->resource);
|
||||||
$newestMTime = filemtime($this->resource);
|
$newestMTime = filemtime($this->resource);
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class FileResource implements ResourceInterface
|
|||||||
*/
|
*/
|
||||||
public function __construct($resource)
|
public function __construct($resource)
|
||||||
{
|
{
|
||||||
$this->resource = realpath($resource);
|
$this->resource = file_exists($resource) ? realpath($resource) : $resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,6 +59,10 @@ class FileResource implements ResourceInterface
|
|||||||
*/
|
*/
|
||||||
public function getModificationTime()
|
public function getModificationTime()
|
||||||
{
|
{
|
||||||
|
if (!$this->exists()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
clearstatcache(true, $this->resource);
|
clearstatcache(true, $this->resource);
|
||||||
|
|
||||||
return filemtime($this->resource);
|
return filemtime($this->resource);
|
||||||
|
Reference in New Issue
Block a user