When clone fails, only remove directories we have created (not other directories)

[?]
Jan 13, 2021, 4:12 PM
SQVWP4LU7AAJSEIHK5CNNUK3XBUVT3FGIJIOPTKMR53PO2P4ARNQC

Dependencies

  • [2] B3QWIGDE Fixing the Git features with the latest Pijul (+ conflicts in Cargo.toml)
  • [3] RGJWLQWB When cloning, try to init *before* setting up the path Drop (pijul::commands::clone::RepoPath)
  • [4] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [5] LYTVEPH3 Avoid cloning into an existing path

Change contents

  • replacement in pijul/src/commands/clone.rs at line 60
    [4.1][4.1:35]()
    let path_ = path.clone();
    [4.1]
    [4.35]
    let repo_path = RepoPath::new(path.clone());
    let repo_path_ = repo_path.clone();
  • replacement in pijul/src/commands/clone.rs at line 63
    [4.72][4.72:131]()
    std::fs::remove_dir_all(&path_).unwrap_or(());
    [4.72]
    [2.1705]
    if repo_path_.remove {
    std::fs::remove_dir_all(&repo_path_.path).unwrap_or(());
    }
  • replacement in pijul/src/commands/clone.rs at line 70
    [4.167][3.0:62](),[3.62][4.167:207](),[4.167][4.167:207]()
    let mut repo = Repository::init(Some(path.clone()))?;
    let repo_path = RepoPath(path);
    [4.167]
    [4.184784]
    let mut repo = Repository::init(Some(path))?;
  • replacement in pijul/src/commands/clone.rs at line 129
    [4.316][4.316:342]()
    struct RepoPath(PathBuf);
    [4.316]
    [4.342]
    #[derive(Debug, Clone)]
    struct RepoPath {
    path: PathBuf,
    remove: bool,
    }
    impl RepoPath {
    fn new(path: PathBuf) -> Self {
    RepoPath {
    remove: std::fs::metadata(&path).is_err(),
    path,
    }
    }
    }
  • replacement in pijul/src/commands/clone.rs at line 146
    [4.393][4.393:449]()
    std::fs::remove_dir_all(&self.0).unwrap_or(());
    [4.393]
    [4.449]
    if self.remove {
    std::fs::remove_dir_all(&self.path).unwrap_or(());
    }