From b181822e90e68f7525341654f58971d1bfcc7834 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 28 May 2015 15:26:56 +0100 Subject: [PATCH] Fix case where touch() fails due to incorrect ownership, fixes #4070 --- src/Composer/Cache.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Composer/Cache.php b/src/Composer/Cache.php index dfecef010..e49edf649 100644 --- a/src/Composer/Cache.php +++ b/src/Composer/Cache.php @@ -136,7 +136,13 @@ class Cache { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); if ($this->enabled && file_exists($this->root . $file)) { - touch($this->root . $file, filemtime($this->root . $file), time()); + 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');