From 90841034879fa0c212875d4e57db337ace5f1432 Mon Sep 17 00:00:00 2001 From: Qrius Date: Thu, 26 Sep 2024 00:11:05 +0200 Subject: Correctly create directories for static content --- src/skaldpress/main.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/skaldpress/main.rs b/src/skaldpress/main.rs index 566fff3..5e44b8d 100644 --- a/src/skaldpress/main.rs +++ b/src/skaldpress/main.rs @@ -444,7 +444,6 @@ fn copy_files_in_directory(directory: &Path, opts: &Opts) -> Result<(), Skaldpre }; if metadata.is_file() { - println!("< Copying {:#?}", path.as_path()); let real_path = match path.strip_prefix(&opts.static_dir) { Ok(r) => r, Err(e) => { @@ -452,7 +451,20 @@ fn copy_files_in_directory(directory: &Path, opts: &Opts) -> Result<(), Skaldpre continue; } }; - let dest_file_path = Path::new(&opts.static_dir).join(real_path); + let dest_file_path = Path::new(&opts.build_dir).join(real_path); + println!( + "< Copying {:#?} -> {:#?}", + path.as_path(), + dest_file_path.as_path() + ); + let Some(dest_dir) = &dest_file_path.parent() else { + println!("\x1b[31mError creating dir {:#?}\x1b[0m", dest_file_path); + continue; + }; + if let Err(e) = std::fs::create_dir_all(&dest_dir) { + println!("\x1b[31mError creating dir {:#?}: {}\x1b[0m", dest_dir, e); + continue; + } if let Err(e) = std::fs::copy(&path, dest_file_path) { println!("\x1b[31mError copying {:#?}: {}\x1b[0m", path.as_path(), e); } -- cgit v1.2.3