diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 6aaa2fa5c..a5590164f 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -203,6 +203,7 @@ TAGSPUBKEY } if ($err = $this->setLocalPhar($localFilename, $tempFilename, $backupFile)) { + @unlink($tempFilename); $io->writeError('The file is corrupted ('.$err->getMessage().').'); $io->writeError('Please re-run the self-update command to try again.'); @@ -312,9 +313,6 @@ TAGSPUBKEY rename($newFilename, $localFilename); } catch (\Exception $e) { - if ($backupTarget) { - @unlink($newFilename); - } if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) { throw $e; }