diff --git a/src/Composer/Cache.php b/src/Composer/Cache.php index 27007a0bb..1253d72ce 100644 --- a/src/Composer/Cache.php +++ b/src/Composer/Cache.php @@ -63,6 +63,9 @@ class Cache { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); if ($this->enabled && file_exists($this->root . $file)) { + if ($this->io->isDebug()) { + $this->io->write('Reading '.$this->root . $file.' from cache'); + } return file_get_contents($this->root . $file); } @@ -74,30 +77,45 @@ class Cache if ($this->enabled) { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); + if ($this->io->isDebug()) { + $this->io->write('Writing '.$this->root . $file.' into cache'); + } return file_put_contents($this->root . $file, $contents); } return false; } + /** + * Copy a file into the cache + */ public function copyFrom($file, $source) { if ($this->enabled) { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); $this->filesystem->ensureDirectoryExists(dirname($this->root . $file)); + if ($this->io->isDebug()) { + $this->io->write('Writing '.$this->root . $file.' into cache'); + } return copy($source, $this->root . $file); } return false; } + /** + * Copy a file out of the cache + */ public function copyTo($file, $target) { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); if ($this->enabled && file_exists($this->root . $file)) { touch($this->root . $file); + if ($this->io->isDebug()) { + $this->io->write('Reading '.$this->root . $file.' from cache'); + } return copy($this->root . $file, $target); }