瀏覽代碼

Avoid failing cleanup when a package gets uninstalled

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

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

@@ -239,13 +239,13 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
         if (file_exists($fileName)) {
             $this->filesystem->unlink($fileName);
         }
-        if ($this->filesystem->isDirEmpty($this->config->get('vendor-dir').'/composer/')) {
+        if (is_dir($path) && $this->filesystem->isDirEmpty($this->config->get('vendor-dir').'/composer/')) {
             $this->filesystem->removeDirectory($this->config->get('vendor-dir').'/composer/');
         }
-        if ($this->filesystem->isDirEmpty($this->config->get('vendor-dir'))) {
+        if (is_dir($path) && $this->filesystem->isDirEmpty($this->config->get('vendor-dir'))) {
             $this->filesystem->removeDirectory($this->config->get('vendor-dir'));
         }
-        if ($this->filesystem->isDirEmpty($path)) {
+        if (is_dir($path) && $this->filesystem->isDirEmpty($path)) {
             $this->filesystem->removeDirectory($path);
         }
     }