Skip to content

Commit

Permalink
Merge pull request #157 from MartinNowack/patch-1
Browse files Browse the repository at this point in the history
Explicitly check if extracting files was successful
  • Loading branch information
MorrisJobke authored Feb 27, 2018
2 parents 6e647cd + 59d33b4 commit ce3b80c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,14 +757,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 ce3b80c

Please sign in to comment.