Skip to content

Commit

Permalink
ZippedResourcePack: ensure non-empty file
Browse files Browse the repository at this point in the history
ZipArchive raises deprecation errors on empty files for some reason
  • Loading branch information
dktapps committed Apr 17, 2022
1 parent 4c9d2a9 commit 52e3f1e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/resourcepacks/ZippedResourcePack.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public function __construct(string $zipPath){
if(!file_exists($zipPath)){
throw new ResourcePackException("File not found");
}
$size = filesize($zipPath);
if($size === false){
throw new ResourcePackException("Unable to determine size of file");
}
if($size === 0){
throw new ResourcePackException("Empty file, probably corrupted");
}

$archive = new \ZipArchive();
if(($openResult = $archive->open($zipPath)) !== true){
Expand Down

0 comments on commit 52e3f1e

Please sign in to comment.