Skip to content

Commit

Permalink
damned if you don't
Browse files Browse the repository at this point in the history
  • Loading branch information
jupyterkat committed Jul 16, 2023
1 parent 07e9c94 commit 77761c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 1 addition & 2 deletions crates/mapdiffbot2/src/job_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ fn render(
)
.context("Rendering added maps")?;
Ok(maps)
})
.context("Rendering modified after and added maps")?;
})?;

//do modified maps
let base_maps = with_checkout(&base_branch, repo, || Ok(load_maps(modified_files, &path)))
Expand Down
11 changes: 8 additions & 3 deletions crates/mapdiffbot2/src/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ pub fn render_map_regions(
};

log::debug!(
"maprender: {map_name} : {}, azure: {}, path: {}",
"maprender: {map_name}, image: {}, azure: {}, path: {}",
image.is_some(),
blob_client.is_some(),
output_dir.display(),
Expand All @@ -391,14 +391,15 @@ pub fn render_map_regions(
))
.join(Path::new(&format!("{z_level}-{filename}")));

log::debug!("file at: {directory:?}");

match (image, blob_client.as_ref()) {
(Some(image), Some(blob_client)) => {
write_to_azure(&directory, blob_client.clone(), &image)?;
log::debug!("Sent to azure: {map_name} {directory:?}");
}
(Some(image), None) => {
write_to_file(&directory, &image)?;

log::debug!("Wrote to file: {map_name} {directory:?}");
}
(_, _) => (),
Expand Down Expand Up @@ -502,7 +503,11 @@ fn compress_image(image: image::RgbaImage) -> Result<Vec<u8>> {
}

fn write_to_file<P: AsRef<Path>>(path: P, image: &image::RgbaImage) -> Result<()> {
std::fs::create_dir_all(&path)?;
std::fs::create_dir_all(
path.as_ref()
.parent()
.ok_or_else(|| eyre::eyre!("Path has no parent!"))?,
)?;

let mut file = std::io::BufWriter::new(std::fs::File::create(path)?);

Expand Down

0 comments on commit 77761c0

Please sign in to comment.