1
0
Fork 0

Clean up properly if self-update fails (#10475)

pull/10477/head
John Stevenson 2022-01-21 11:55:42 +00:00 committed by GitHub
parent e3d99cac59
commit 0228e5b47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -468,6 +468,7 @@ TAGSPUBKEY
return $this->tryAsWindowsAdmin($localFilename, $newFilename); return $this->tryAsWindowsAdmin($localFilename, $newFilename);
} }
@unlink($newFilename);
$action = 'Composer '.($backupTarget ? 'update' : 'rollback'); $action = 'Composer '.($backupTarget ? 'update' : 'rollback');
throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage()); throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
} }
@ -620,7 +621,7 @@ EOT;
exec('"'.$script.'"'); exec('"'.$script.'"');
@unlink($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)) { if ($result = Filesystem::isReadable($localFilename) && (hash_file('sha256', $localFilename) === $checksum)) {
$io->writeError('<info>Operation succeeded.</info>'); $io->writeError('<info>Operation succeeded.</info>');
@unlink($newFilename); @unlink($newFilename);