Resolve the destination path. If destination is a directory, append the source filename.
(&self, repo_root: &Path, source: &str, dest: &str)
| 154 | /// |
| 155 | /// If destination is a directory, append the source filename. |
| 156 | fn resolve_destination(&self, repo_root: &Path, source: &str, dest: &str) -> String { |
| 157 | let dest_path = repo_root.join(dest); |
| 158 | |
| 159 | // If destination is an existing directory, move INTO it |
| 160 | if dest_path.is_dir() { |
| 161 | let source_name = Path::new(source) |
| 162 | .file_name() |
| 163 | .map(|n| n.to_string_lossy().to_string()) |
| 164 | .unwrap_or_else(|| source.to_string()); |
| 165 | format!("{}/{}", dest.trim_end_matches('/'), source_name) |
| 166 | } else { |
| 167 | dest.to_string() |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | /// Move the actual file on disk. |
| 172 | fn move_file_on_disk(&self, repo_root: &Path, from: &str, to: &str) -> std::io::Result<()> { |