diff --git a/crates/forest/src/plan_reconciler.rs b/crates/forest/src/plan_reconciler.rs index 70ca4d9..d36de6d 100644 --- a/crates/forest/src/plan_reconciler.rs +++ b/crates/forest/src/plan_reconciler.rs @@ -4,43 +4,7 @@ use anyhow::Context; use crate::model::Project; -pub mod local { - use std::path::Path; - - use anyhow::Context; - - pub async fn reconcile(source: &Path, dest: &Path) -> anyhow::Result<()> { - for entry in walkdir::WalkDir::new(source) { - let entry = entry?; - let rel = entry.path().strip_prefix(source)?; - let metadata = entry.metadata()?; - - if metadata.is_file() { - tracing::trace!("copying file: {}", rel.display()); - let dest_path = dest.join(rel); - - tokio::fs::copy(entry.path(), &dest_path) - .await - .context(anyhow::anyhow!( - "failed to file directory at: {}", - dest_path.display() - ))?; - } else if metadata.is_dir() { - let dest_path = dest.join(rel); - - tracing::trace!("creating directory: {}", dest_path.display()); - tokio::fs::create_dir_all(&dest_path) - .await - .context(anyhow::anyhow!( - "failed to create directory at: {}", - dest_path.display() - ))?; - } - } - - Ok(()) - } -} +pub mod local; #[derive(Default)] pub struct PlanReconciler {} diff --git a/crates/forest/src/plan_reconciler/local.rs b/crates/forest/src/plan_reconciler/local.rs new file mode 100644 index 0000000..9e465a4 --- /dev/null +++ b/crates/forest/src/plan_reconciler/local.rs @@ -0,0 +1,35 @@ +use std::path::Path; + +use anyhow::Context; + +pub async fn reconcile(source: &Path, dest: &Path) -> anyhow::Result<()> { + for entry in walkdir::WalkDir::new(source) { + let entry = entry?; + let rel = entry.path().strip_prefix(source)?; + let metadata = entry.metadata()?; + + if metadata.is_file() { + tracing::trace!("copying file: {}", rel.display()); + let dest_path = dest.join(rel); + + tokio::fs::copy(entry.path(), &dest_path) + .await + .context(anyhow::anyhow!( + "failed to file directory at: {}", + dest_path.display() + ))?; + } else if metadata.is_dir() { + let dest_path = dest.join(rel); + + tracing::trace!("creating directory: {}", dest_path.display()); + tokio::fs::create_dir_all(&dest_path) + .await + .context(anyhow::anyhow!( + "failed to create directory at: {}", + dest_path.display() + ))?; + } + } + + Ok(()) +}