Jelajahi Sumber

Archive: cleanup temp dir on download error

Stephan Vock 6 tahun lalu
induk
melakukan
59360983c6
1 mengubah file dengan 7 tambahan dan 2 penghapusan
  1. 7 2
      src/Composer/Package/Archiver/ArchiveManager.php

+ 7 - 2
src/Composer/Package/Archiver/ArchiveManager.php

@@ -147,8 +147,13 @@ class ArchiveManager
             $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
             $filesystem->ensureDirectoryExists($sourcePath);
 
-            // Download sources
-            $this->downloadManager->download($package, $sourcePath);
+            try {
+                // Download sources
+                $this->downloadManager->download($package, $sourcePath);
+            } catch (\Exception $e) {
+                $filesystem->removeDirectory($sourcePath);
+                throw  $e;
+            }
 
             // Check exclude from downloaded composer.json
             if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {