From a85c12a12fbc7a44252a78f76d02e75216c257c9 Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 16 Jul 2025 12:32:00 +0000 Subject: [PATCH] add src and dst detection for utils copy_dir Signed-off-by: tommady --- src/utils/fs.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/fs.rs b/src/utils/fs.rs index 4752e63..f5a23fc 100644 --- a/src/utils/fs.rs +++ b/src/utils/fs.rs @@ -212,6 +212,12 @@ pub fn try_infer_extension(path: &Path) -> Option { /// Copy the src directory into the dst directory recursively pub fn copy_dir(src: &Path, dst: &Path) -> crate::Result<()> { + if !src.exists() || !dst.exists() { + return Err(crate::Error::NotFound { + error_title: "source or destination directory does not exist".to_string(), + }); + } + for entry in fs::read_dir(src)? { let entry = entry?; let ty = entry.file_type()?;