瀏覽代碼

Only empty dir before actually installing packages, fixes #7929

Jordi Boggiano 6 年之前
父節點
當前提交
898ba6f869
共有 2 個文件被更改,包括 3 次插入1 次删除
  1. 2 0
      src/Composer/Downloader/ArchiveDownloader.php
  2. 1 1
      src/Composer/Downloader/FileDownloader.php

+ 2 - 0
src/Composer/Downloader/ArchiveDownloader.php

@@ -38,6 +38,8 @@ abstract class ArchiveDownloader extends FileDownloader
             $this->io->writeError('Extracting archive', false);
         }
 
+        $this->filesystem->emptyDirectory($path);
+
         $temporaryDir = $this->config->get('vendor-dir').'/composer/'.substr(md5(uniqid('', true)), 0, 8);
         $fileName = $this->getFileName($package, $path);
 

+ 1 - 1
src/Composer/Downloader/FileDownloader.php

@@ -101,7 +101,6 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
             );
         }
 
-        $this->filesystem->emptyDirectory($path);
         $fileName = $this->getFileName($package, $path);
 
         $io = $this->io;
@@ -229,6 +228,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
             $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
         }
 
+        $this->filesystem->emptyDirectory($path);
         $this->filesystem->ensureDirectoryExists($path);
         $this->filesystem->rename($this->getFileName($package, $path), $path . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
     }