1
0
Fork 0

Merge pull request #5021 from vlakoff/self-update

Adjustments in self-update command in case of corrupted file
pull/5025/head
Jordi Boggiano 2016-03-08 14:41:06 +01:00
commit fe134d3359
1 changed files with 2 additions and 4 deletions

View File

@ -203,6 +203,7 @@ TAGSPUBKEY
} }
if ($err = $this->setLocalPhar($localFilename, $tempFilename, $backupFile)) { if ($err = $this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
@unlink($tempFilename);
$io->writeError('<error>The file is corrupted ('.$err->getMessage().').</error>'); $io->writeError('<error>The file is corrupted ('.$err->getMessage().').</error>');
$io->writeError('<error>Please re-run the self-update command to try again.</error>'); $io->writeError('<error>Please re-run the self-update command to try again.</error>');
@ -281,7 +282,7 @@ TAGSPUBKEY
$io = $this->getIO(); $io = $this->getIO();
$io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion)); $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
if ($err = $this->setLocalPhar($localFilename, $oldFile)) { if ($err = $this->setLocalPhar($localFilename, $oldFile)) {
$io->writeError('<error>The backup file was corrupted ('.$err->getMessage().') and has been removed.</error>'); $io->writeError('<error>The backup file was corrupted ('.$err->getMessage().').</error>');
return 1; return 1;
} }
@ -312,9 +313,6 @@ TAGSPUBKEY
rename($newFilename, $localFilename); rename($newFilename, $localFilename);
} catch (\Exception $e) { } catch (\Exception $e) {
if ($backupTarget) {
@unlink($newFilename);
}
if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) { if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
throw $e; throw $e;
} }