Skip to content

Commit

Permalink
Fix duplicated code
Browse files Browse the repository at this point in the history
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Feb 27, 2018
1 parent ce3b80c commit 7a1b76d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions lib/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7a1b76d

Please sign in to comment.