From 59360983c604bb44e8ada7a281c81046f8cd4ff5 Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Thu, 17 Jan 2019 12:46:57 +0100 Subject: [PATCH] Archive: cleanup temp dir on download error --- src/Composer/Package/Archiver/ArchiveManager.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/Archiver/ArchiveManager.php b/src/Composer/Package/Archiver/ArchiveManager.php index 22f8eeafe..6f8fa8a01 100644 --- a/src/Composer/Package/Archiver/ArchiveManager.php +++ b/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')) {