LYTVEPH3W5UHF7MAYFWBT6NVNC42HEVKJGGMFDKUDZDNDOI33YJQC
TPEH2XNBS5RO4IEVKENVF6P65AH7IX64KK2JAYMSJT3J5GXO67EAC
SXEYMYF7P4RZMZ46WPL4IZUTSQ2ATBWYZX7QNVMS3SGOYXYOHAGQC
Q45QHPO4HDTEZF2W4UDZSYYQ46BPEIWSW4GJILZR5HTJNLKXJABQC
L4JXJHWXYNCL4QGJXNKKTOKKTAXKKXBJUUY7HFZGEUZ5A2V5H34QC
L4LAD4XMVJZIZGOA4TTFZETDAHNONEPYBYENTTCHMOYCWCV5B4XQC
BT2ZHPY4LTECZDNPNLX5IUAEA6CYB4RRBGVBXUNK3ARHMWQK7KHAC
2K7JLB4Z7BS5VFNWD4DO3MKYU7VNPA5MTVHVSDI3FQZ5ICM6XM6QC
XWETQ4DE4KL2GQWSEBE5NENLTSLIDF7RIWOCCVWJFQOVQJE5P33AC
SAGSYAPXQ2T6GC3B3TNRPNFTZMS7UMME6YQGSF5MOIM66S5NKB2QC
let parent = std::fs::canonicalize(path.parent().unwrap())?;
let temp = TempDir::new_in(&parent)?;
debug!("temp = {:?}", temp.path());
let mut repo = Repository::init(Some(temp.path().to_path_buf()))?;
let path_ = path.clone();
ctrlc::set_handler(move || {
std::fs::remove_dir_all(&path_).unwrap_or(());
})
.unwrap_or(());
let repo_path = RepoPath(path);
let mut repo = Repository::init(Some(repo_path.0.clone()))?;
let temp = temp.into_path();
if let Err(e) = std::fs::rename(&temp, &path) {
let mut stderr = std::io::stderr();
writeln!(
stderr,
"Error while renaming {:?} to {:?}: {}",
temp, path, e
)?;
std::fs::remove_dir_all(temp).unwrap_or(());
}
std::mem::forget(repo_path);
struct RepoPath(PathBuf);
impl Drop for RepoPath {
fn drop(&mut self) {
std::fs::remove_dir_all(&self.0).unwrap_or(());
}
}