1
0
Fork 0

Fix Cache::gc() when COMPOSER_CACHE_DIR=/dev/null

If we set COMPOSER_CACHE_DIR=/dev/null, and the garbage collector
is triggered, we end up with the following error :

The "/dev/null/" directory does not exist.

This is because the Cache::gc() function does not check for Cache::enabled
and instanciates a Finder unconditionnaly.

Fix this by adding a check on Cache::enabled.
pull/2695/head
Guillaume LECERF 2014-02-12 14:48:56 +01:00
parent 7343198817
commit 44fd75ef38
1 changed files with 23 additions and 18 deletions

View File

@ -143,6 +143,8 @@ class Cache
}
public function gc($ttl, $maxSize)
{
if ($this->enabled)
{
$expire = new \DateTime();
$expire->modify('-'.$ttl.' seconds');
@ -168,6 +170,9 @@ class Cache
return true;
}
return false;
}
public function sha1($file)
{
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);