[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:
everzet 2012-06-20 10:19:09 +02:00
parent 56b60c8d46
commit 241aa92cc5
2 changed files with 13 additions and 1 deletions

View File

@ -75,6 +75,10 @@ class DirectoryResource implements ResourceInterface
*/
public function getFilteredResources()
{
if (!$this->exists()) {
return array();
}
$iterator = new \DirectoryIterator($this->resource);
$resources = array();
@ -166,6 +170,10 @@ class DirectoryResource implements ResourceInterface
*/
public function getModificationTime()
{
if (!$this->exists()) {
return -1;
}
clearstatcache(true, $this->resource);
$newestMTime = filemtime($this->resource);

View File

@ -29,7 +29,7 @@ class FileResource implements ResourceInterface
*/
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()
{
if (!$this->exists()) {
return -1;
}
clearstatcache(true, $this->resource);
return filemtime($this->resource);