1
0
Fork 0

Fix case where touch() fails due to incorrect ownership, fixes #4070

pull/4081/head
Jordi Boggiano 2015-05-28 15:26:56 +01:00
parent fbc0fa9688
commit b181822e90
1 changed files with 7 additions and 1 deletions

View File

@ -136,7 +136,13 @@ class Cache
{
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
if ($this->enabled && file_exists($this->root . $file)) {
try {
touch($this->root . $file, filemtime($this->root . $file), time());
} catch (\ErrorException $e) {
// fallback in case the above failed due to incorrect ownership
// see https://github.com/composer/composer/issues/4070
touch($this->root . $file);
}
if ($this->io->isDebug()) {
$this->io->writeError('Reading '.$this->root . $file.' from cache');