浏览代码

Avoid emptying the directory before extracting an archive into it, check that it is empty instead

Jordi Boggiano 5 年之前
父节点
当前提交
73251691a0
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      src/Composer/Downloader/ArchiveDownloader.php

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

@@ -38,7 +38,10 @@ abstract class ArchiveDownloader extends FileDownloader
             $this->io->writeError('Extracting archive', false);
         }
 
-        $this->filesystem->emptyDirectory($path);
+        $this->filesystem->ensureDirectoryExists($path);
+        if (!$this->filesystem->isDirEmpty($path)) {
+            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);
         $fileName = $this->getFileName($package, $path);