(src: &Path, dest: &Path)
| 2050 | } |
| 2051 | |
| 2052 | fn 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")] |
| 2075 | fn clone_dir_command(src: &Path, dest: &Path) -> std::io::Result<std::process::ExitStatus> { |
no test coverage detected