MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / try_clone_dir

Function try_clone_dir

src/pglite/base.rs:2052–2072  ·  view source on GitHub ↗
(src: &Path, dest: &Path)

Source from the content-addressed store, hash-verified

2050}
2051
2052fn try_clone_dir(src: &Path, dest: &Path) -> Result<bool> {
2053 if dest.exists() {
2054 fs::remove_dir_all(dest).with_context(|| format!("remove {}", dest.display()))?;
2055 }
2056 if let Some(parent) = dest.parent() {
2057 fs::create_dir_all(parent).with_context(|| format!("create {}", parent.display()))?;
2058 }
2059
2060 let status = clone_dir_command(src, dest);
2061 match status {
2062 Ok(status) if status.success() && dest.exists() => Ok(true),
2063 Ok(_) | Err(_) => {
2064 if dest.exists() {
2065 fs::remove_dir_all(dest).with_context(|| {
2066 format!("remove failed cloned directory {}", dest.display())
2067 })?;
2068 }
2069 Ok(false)
2070 }
2071 }
2072}
2073
2074#[cfg(target_os = "linux")]
2075fn clone_dir_command(src: &Path, dest: &Path) -> std::io::Result<std::process::ExitStatus> {

Callers 1

Calls 1

clone_dir_commandFunction · 0.85

Tested by

no test coverage detected