mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-03 06:09:07 +02:00
Store source modified timestamp with processed, lightmap and map tiles
Allows to check whether the source is newer than the last update of the output files.
This commit is contained in:
parent
e18d4cea82
commit
628a702fd7
4 changed files with 75 additions and 15 deletions
|
@ -1,3 +1,5 @@
|
|||
use std::time::SystemTime;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
|
||||
use minedmap::{
|
||||
|
@ -17,9 +19,12 @@ impl<'a> TileRenderer<'a> {
|
|||
TileRenderer { config }
|
||||
}
|
||||
|
||||
fn load_region(&self, coords: TileCoords) -> Result<ProcessedRegion> {
|
||||
fn load_region(&self, coords: TileCoords) -> Result<(ProcessedRegion, SystemTime)> {
|
||||
let processed_path = self.config.processed_path(coords);
|
||||
storage::read(&processed_path).context("Failed to load processed region data")
|
||||
let timestamp = fs::modified_timestamp(&processed_path)?;
|
||||
let region =
|
||||
storage::read(&processed_path).context("Failed to load processed region data")?;
|
||||
Ok((region, timestamp))
|
||||
}
|
||||
|
||||
fn render_chunk(image: &mut image::RgbaImage, coords: ChunkCoords, chunk: &ProcessedChunk) {
|
||||
|
@ -69,11 +74,11 @@ impl<'a> TileRenderer<'a> {
|
|||
.display(),
|
||||
);
|
||||
|
||||
let region = self.load_region(coords)?;
|
||||
let (region, timestamp) = self.load_region(coords)?;
|
||||
let mut image = image::RgbaImage::new(N, N);
|
||||
Self::render_region(&mut image, ®ion);
|
||||
|
||||
fs::create_with_tmpfile(&output_path, |file| {
|
||||
fs::create_with_timestamp(&output_path, timestamp, |file| {
|
||||
image
|
||||
.write_to(file, image::ImageFormat::Png)
|
||||
.context("Failed to save image")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue