Skip to content

Commit

Permalink
core: region_processor: ignore empty region files
Browse files Browse the repository at this point in the history
Minecraft generates empty region files in some cases. Just ignore these
files instead of printing an error message for each.
  • Loading branch information
neocturne committed Jun 14, 2024
1 parent 66189d2 commit 0f20d20
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/core/region_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,20 @@ impl<'a> RegionProcessor<'a> {
})?
.filter_map(|entry| entry.ok())
.filter(|entry| {
// We are only interested in regular files
matches!(
entry.file_type().map(|file_type| file_type.is_file()),
Ok(true)
)
(|| {
// We are only interested in regular files
let file_type = entry.file_type().ok()?;
if !file_type.is_file() {
return None;
}

let metadata = entry.metadata().ok()?;
if metadata.len() == 0 {
return None;
}
Some(())
})()
.is_some()
})
.filter_map(|entry| parse_region_filename(&entry.file_name()))
.collect())
Expand Down

0 comments on commit 0f20d20

Please sign in to comment.