Skip to content

Commit 07188fe

Browse files
committed
Fix new version of create_dir_all
It will now correctly fail on existing non-directories.
1 parent 2339a0a commit 07188fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ impl DirBuilder {
17771777
fn create_dir_all(&self, path: &Path) -> io::Result<()> {
17781778
match self.inner.mkdir(path) {
17791779
Ok(()) => return Ok(()),
1780-
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => return Ok(()),
1780+
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists && path.is_dir() => return Ok(()),
17811781
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {}
17821782
Err(e) => return Err(e),
17831783
}
@@ -1787,7 +1787,7 @@ impl DirBuilder {
17871787
}
17881788
match self.inner.mkdir(path) {
17891789
Ok(()) => Ok(()),
1790-
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()),
1790+
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists && path.is_dir() => Ok(()),
17911791
Err(e) => Err(e),
17921792
}
17931793
}

0 commit comments

Comments
 (0)