LevelDB: Check for LEVELDB_ZLIB_RAW_COMPRESSION when checking for the extension's presence

We always want to validate that the leveldb provided supports the world format.
This commit is contained in:
Dylan K. Taylor 2017-12-31 17:49:02 +00:00
parent 5132ab6cd9
commit a0a2ea01bc

View File

@ -84,6 +84,10 @@ class LevelDB extends BaseLevelProvider{
if(!extension_loaded('leveldb')){ if(!extension_loaded('leveldb')){
throw new LevelException("The leveldb PHP extension is required to use this world format"); throw new LevelException("The leveldb PHP extension is required to use this world format");
} }
if(!defined('LEVELDB_ZLIB_RAW_COMPRESSION')){
throw new LevelException("Given version of php-leveldb doesn't support zlib raw compression");
}
} }
public function __construct(Level $level, string $path){ public function __construct(Level $level, string $path){
@ -103,10 +107,6 @@ class LevelDB extends BaseLevelProvider{
throw new LevelException("Invalid level.dat"); throw new LevelException("Invalid level.dat");
} }
if(!defined('LEVELDB_ZLIB_RAW_COMPRESSION')){
throw new LevelException("Given version of php-leveldb doesn't support zlib raw compression");
}
$this->db = new \LevelDB($this->path . "/db", [ $this->db = new \LevelDB($this->path . "/db", [
"compression" => LEVELDB_ZLIB_RAW_COMPRESSION "compression" => LEVELDB_ZLIB_RAW_COMPRESSION
]); ]);