From 7a1b76d4ae86133b4902ffd7a535df291098fae7 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 27 Feb 2018 15:28:06 +0100 Subject: [PATCH] Fix duplicated code Signed-off-by: Morris Jobke --- index.php | 4 ++-- lib/Updater.php | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index 4b04e622..75574cc5 100644 --- a/index.php +++ b/index.php @@ -764,10 +764,10 @@ public function extractDownload() { $zip->close(); $state = unlink($downloadedFilePath); if($state === false) { - throw new \Exception('Can\'t unlink '. $downloadedFilePath); + throw new \Exception("Can't unlink ". $downloadedFilePath); } } else { - throw new \Exception('Can\'t handle ZIP file. Error code is: '.$zipState); + throw new \Exception("Can't handle ZIP file. Error code is: ".$zipState); } // Ensure that the downloaded version is not lower diff --git a/lib/Updater.php b/lib/Updater.php index f85b7dbe..393db42f 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -642,14 +642,17 @@ public function extractDownload() { $zip = new \ZipArchive; $zipState = $zip->open($downloadedFilePath); if ($zipState === true) { - $zip->extractTo(dirname($downloadedFilePath)); + $extraction = $zip->extractTo(dirname($downloadedFilePath)); + if($extraction === false) { + throw new \Exception('Error during unpacking zipfile: '.($zip->getStatusString())); + } $zip->close(); $state = unlink($downloadedFilePath); if($state === false) { - throw new \Exception('Cant unlink '. $downloadedFilePath); + throw new \Exception("Can't unlink ". $downloadedFilePath); } } else { - throw new \Exception('Cant handle ZIP file. Error code is: '.$zipState); + throw new \Exception("Can't handle ZIP file. Error code is: ".$zipState); } // Ensure that the downloaded version is not lower