From e34c10bc34ac4ba5e2b26e44eb30c257e0a4a2c5 Mon Sep 17 00:00:00 2001 From: Valerio Ageno <51341197+Valerioageno@users.noreply.github.com> Date: Fri, 28 Feb 2025 17:41:01 +0100 Subject: [PATCH] fix: build script for creation of parent directories (#614) --- crates/tuono/src/route.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/tuono/src/route.rs b/crates/tuono/src/route.rs index 241f701b..54268054 100644 --- a/crates/tuono/src/route.rs +++ b/crates/tuono/src/route.rs @@ -180,11 +180,13 @@ impl Route { } }; - if !parent_dir.is_dir() || create_all(parent_dir, false).is_err() { - return Err(format!( - "Failed to create the parent directory {:?}", - parent_dir - )); + if !parent_dir.is_dir() { + if let Err(err) = create_all(parent_dir, false) { + return Err(format!( + "Failed to create the parent directory {:?}\nError: {err}", + parent_dir + )); + } } trace!("Saving the HTML file: {:?}", file_path); @@ -214,11 +216,13 @@ impl Route { } }; - if !data_parent_dir.is_dir() && create_all(data_parent_dir, false).is_err() { - return Err(format!( - "Failed to create the parent directory {:?}", - data_parent_dir - )); + if !data_parent_dir.is_dir() { + if let Err(err) = create_all(data_parent_dir, false) { + return Err(format!( + "Failed to create the parent directory {:?}\n Error: {err}", + data_parent_dir + )); + } } let base = Url::parse("http://localhost:3000/__tuono/data").unwrap();