diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 541636c1ef16..daf1b55ff386 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -468,6 +468,7 @@ protected function setLocalPhar($localFilename, $newFilename, $backupTarget = nu return $this->tryAsWindowsAdmin($localFilename, $newFilename); } + @unlink($newFilename); $action = 'Composer '.($backupTarget ? 'update' : 'rollback'); throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage()); } @@ -620,7 +621,7 @@ protected function tryAsWindowsAdmin($localFilename, $newFilename) exec('"'.$script.'"'); @unlink($script); - // see if the file was moved and is still accessible + // see if the file was copied and is still accessible if ($result = Filesystem::isReadable($localFilename) && (hash_file('sha256', $localFilename) === $checksum)) { $io->writeError('Operation succeeded.'); @unlink($newFilename);