Browse Source

Make sure we get a temporary dir which is unique

Jordi Boggiano 5 years ago
parent
commit
918768fc54
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/Composer/Downloader/ArchiveDownloader.php

+ 4 - 1
src/Composer/Downloader/ArchiveDownloader.php

@@ -43,7 +43,10 @@ abstract class ArchiveDownloader extends FileDownloader
             throw new \RuntimeException('Expected empty path to extract '.$package.' into but directory exists: '.$path);
         }
 
-        $temporaryDir = $this->config->get('vendor-dir').'/composer/'.substr(md5(uniqid('', true)), 0, 8);
+        do {
+            $temporaryDir = $this->config->get('vendor-dir').'/composer/'.substr(md5(uniqid('', true)), 0, 8);
+        } while (is_dir($temporaryDir));
+
         $fileName = $this->getFileName($package, $path);
 
         try {