RegionLoader: Switch to using named constructors

this makes the code more self-descriptive, and also helps to detect potential bugs.
This commit is contained in:
Dylan K. Taylor
2021-04-15 21:57:23 +01:00
parent e8dd4de5c8
commit 5d83f4670a
4 changed files with 56 additions and 22 deletions

View File

@ -108,7 +108,7 @@ function main(array $argv) : int{
$totalCount = count($files);
foreach($files as $file => $size){
try{
$oldRegion = new RegionLoader($file);
$oldRegion = RegionLoader::loadExisting($file);
}catch(CorruptedRegionException $e){
$logger->error("Damaged region in file $file (" . $e->getMessage() . "), skipping");
$corruptedFiles[] = $file;
@ -117,7 +117,7 @@ function main(array $argv) : int{
}
$newFile = $file . ".compacted";
$newRegion = new RegionLoader($newFile);
$newRegion = RegionLoader::createNew($newFile);
$emptyRegion = true;
$corruption = false;