Browse Source

Create parent directory only

master
Thomas Forgione 2 months ago
parent
commit
5172e2cb57
Signed by: Thomas Forgione <thomas@forgione.fr> GPG Key ID: 203DAEA747F48F41
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      src/git.rs

+ 4
- 1
src/git.rs View File

@@ -92,7 +92,10 @@ fn clone_dirty<P: AsRef<Path>>(url: &str, place: P) -> Result<()> {
92 92
         return Err(Error::PathAlreadyExists);
93 93
     }
94 94
 
95
-    create_dir_all(place)?;
95
+    // Need to create the parent dir only if it exists
96
+    if let Some(parent) = place.parent() {
97
+        create_dir_all(parent)?;
98
+    }
96 99
 
97 100
     let command = Command::new("git")
98 101
         .args(&["clone", &url, &place.display().to_string()])

Loading…
Cancel
Save