diff --git a/src/Composer/Cache.php b/src/Composer/Cache.php index c4bb4b2eb..df45e66ed 100644 --- a/src/Composer/Cache.php +++ b/src/Composer/Cache.php @@ -115,7 +115,8 @@ class Cache $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG); try { - return file_put_contents($this->root . $file.'.tmp', $contents) !== false && rename($this->root . $file . '.tmp', $this->root . $file); + $tempFileName = $this->root . $file . uniqid('.tmp.', true); + return file_put_contents($tempFileName, $contents) !== false && rename($tempFileName, $this->root . $file); } catch (\ErrorException $e) { $this->io->writeError('Failed to write into cache: '.$e->getMessage().'', true, IOInterface::DEBUG); if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {