core/region_processor: make regular processing errors non-fatal again

Never fail because of invalid save files.
This commit is contained in:
Matthias Schiffer 2023-10-12 19:49:26 +02:00
parent 09374d755e
commit fd48f94f16
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -5,7 +5,7 @@ use std::{ffi::OsStr, path::Path, time::SystemTime};
use anyhow::{Context, Result};
use indexmap::IndexSet;
use rayon::prelude::*;
use tracing::{debug, info};
use tracing::{debug, info, warn};
use super::common::*;
use crate::{
@ -168,6 +168,7 @@ impl<'a> RegionProcessor<'a> {
debug!("Processing region r.{}.{}.mca", coords.x, coords.z);
if let Err(err) = (|| -> Result<()> {
crate::nbt::region::from_file(input_path)?.foreach_chunk(
|chunk_coords, data: world::de::Chunk| {
let Some(layer::LayerData {
@ -192,7 +193,22 @@ impl<'a> RegionProcessor<'a> {
Ok(())
},
)?;
)
})() {
if output_timestamp.is_some() && lightmap_timestamp.is_some() {
warn!(
"Failed to process region {:?}, using old data: {:?}",
coords, err
);
return Ok(RegionProcessorStatus::ErrorOk);
} else {
warn!(
"Failed to process region {:?}, no old data available: {:?}",
coords, err
);
return Ok(RegionProcessorStatus::ErrorMissing);
}
}
if Some(input_timestamp) > output_timestamp {
Self::save_region(&output_path, &processed_region, input_timestamp)?;