mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-03 06:09:07 +02:00
io/storage: use fs::create_with_tmpfile() helper
This commit is contained in:
parent
1abb260997
commit
587db0464c
2 changed files with 5 additions and 17 deletions
|
@ -63,19 +63,8 @@ impl<'a> RegionProcessor<'a> {
|
|||
}
|
||||
|
||||
fn save_region(&self, coords: RegionCoords, processed_region: &ProcessedRegion) -> Result<()> {
|
||||
let tmp_path = self.config.processed_path(coords, true);
|
||||
storage::write(&tmp_path, processed_region)?;
|
||||
|
||||
let output_path = self.config.processed_path(coords, false);
|
||||
fs::rename(&tmp_path, &output_path).with_context(|| {
|
||||
format!(
|
||||
"Failed to rename {} to {}",
|
||||
tmp_path.display(),
|
||||
output_path.display(),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
storage::write(&output_path, processed_region)
|
||||
}
|
||||
|
||||
fn save_lightmap(&self, coords: RegionCoords, lightmap: &image::GrayAlphaImage) -> Result<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue