diff --git a/src/Updater.php b/src/Updater.php index 0e03277..405200f 100644 --- a/src/Updater.php +++ b/src/Updater.php @@ -137,9 +137,19 @@ public function update() || (!is_bool($this->newVersionAvailable) && !$this->hasUpdate())) { return false; } + $this->backupPhar(); - $this->downloadPhar(); + + try { + $this->downloadPhar(); + } catch (\Exception $e) { + restore_error_handler(); + $this->cleanupAfterError(); + throw $e; + } + $this->replacePhar(); + return true; } @@ -375,13 +385,7 @@ protected function downloadPhar() } } - try { - $this->validatePhar($this->getTempPharFile()); - } catch (\Exception $e) { - restore_error_handler(); - $this->cleanupAfterError(); - throw $e; - } + $this->validatePhar($this->getTempPharFile()); } protected function replacePhar() @@ -498,7 +502,7 @@ protected function validatePhar($phar) protected function cleanupAfterError() { - //@unlink($this->getBackupPharFile()); + @unlink($this->getBackupPharFile()); @unlink($this->getTempPharFile()); @unlink($this->getTempPubKeyFile()); }