Skip to content

Commit c3e2eaf

Browse files
committed
Fix problems found on Windows in dir_create_all
Ignore the type of error altogether. The rationale is: it doesn't matter what was the problem if the directory is there. In the previous versions if the directory was there already we wouldn't even attempt to create it, so we wouldn't know about the problem neither. Make test path length smaller in `concurrent_recursive_mkdir` test.
1 parent a51c6aa commit c3e2eaf

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/libstd/fs.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,8 +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)
1781-
if e.kind() == io::ErrorKind::AlreadyExists && path.is_dir() => return Ok(()),
1780+
Err(_) if path.is_dir() => return Ok(()),
17821781
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {}
17831782
Err(e) => return Err(e),
17841783
}
@@ -1788,7 +1787,7 @@ impl DirBuilder {
17881787
}
17891788
match self.inner.mkdir(path) {
17901789
Ok(()) => Ok(()),
1791-
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists && path.is_dir() => Ok(()),
1790+
Err(_) if path.is_dir() => Ok(()),
17921791
Err(e) => Err(e),
17931792
}
17941793
}
@@ -2280,7 +2279,7 @@ mod tests {
22802279

22812280
#[test]
22822281
fn concurrent_recursive_mkdir() {
2283-
for _ in 0..100 {
2282+
for _ in 0..50 {
22842283
let mut dir = tmpdir().join("a");
22852284
for _ in 0..100 {
22862285
dir = dir.join("a");

0 commit comments

Comments
 (0)