Browse Source

Fail hard if a package can not be properly removed

Jordi Boggiano 13 years ago
parent
commit
9371253e38

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

@@ -101,7 +101,9 @@ class FileDownloader implements DownloaderInterface
      */
     public function remove(PackageInterface $package, $path)
     {
-        $this->filesystem->removeDirectory($path);
+        if (!$this->filesystem->removeDirectory($path)) {
+            throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
+        }
     }
 
     /**

+ 3 - 1
src/Composer/Downloader/VcsDownloader.php

@@ -77,7 +77,9 @@ abstract class VcsDownloader implements DownloaderInterface
     public function remove(PackageInterface $package, $path)
     {
         $this->enforceCleanDirectory($path);
-        $this->filesystem->removeDirectory($path);
+        if (!$this->filesystem->removeDirectory($path)) {
+            throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
+        }
     }
 
     /**

+ 1 - 1
src/Composer/Util/Filesystem.php

@@ -34,7 +34,7 @@ class Filesystem
         // clear stat cache because external processes aren't tracked by the php stat cache
         clearstatcache();
 
-        return $result;
+        return $result && !is_dir($directory);
     }
 
     public function ensureDirectoryExists($directory)