diff options
author | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
---|---|---|
committer | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
commit | 90841034879fa0c212875d4e57db337ace5f1432 (patch) | |
tree | 643c05fd3d52639615ddd7689e116ca1940b7868 /src | |
parent | 21c9202896c2e43065274b7999eb6a8b56f9aa5b (diff) | |
download | skaldpress-90841034879fa0c212875d4e57db337ace5f1432.tar.gz skaldpress-90841034879fa0c212875d4e57db337ace5f1432.zip |
Correctly create directories for static content
Diffstat (limited to 'src')
-rw-r--r-- | src/skaldpress/main.rs | 16 |
1 files 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); } |