File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -1782,7 +1782,7 @@ impl DirBuilder {
1782
1782
Err ( e) => return Err ( e) ,
1783
1783
}
1784
1784
match path. parent ( ) {
1785
- Some ( p) => try!( create_dir_all ( p) ) ,
1785
+ Some ( p) => try!( self . create_dir_all ( p) ) ,
1786
1786
None => return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "failed to create whole tree" ) ) ,
1787
1787
}
1788
1788
match self . inner . mkdir ( path) {
@@ -1809,6 +1809,7 @@ mod tests {
1809
1809
use rand:: { StdRng , Rng } ;
1810
1810
use str;
1811
1811
use sys_common:: io:: test:: { TempDir , tmpdir} ;
1812
+ use thread;
1812
1813
1813
1814
#[ cfg( windows) ]
1814
1815
use os:: windows:: fs:: { symlink_dir, symlink_file} ;
@@ -2276,6 +2277,26 @@ mod tests {
2276
2277
assert ! ( result. is_err( ) ) ;
2277
2278
}
2278
2279
2280
+ #[ test]
2281
+ fn concurrent_recursive_mkdir ( ) {
2282
+ for _ in 0 ..100 {
2283
+ let mut dir = tmpdir ( ) . join ( "a" ) ;
2284
+ for _ in 0 ..100 {
2285
+ dir = dir. join ( "a" ) ;
2286
+ }
2287
+ let mut join = vec ! ( ) ;
2288
+ for _ in 0 ..8 {
2289
+ let dir = dir. clone ( ) ;
2290
+ join. push ( thread:: spawn ( move || {
2291
+ check ! ( fs:: create_dir_all( & dir) ) ;
2292
+ } ) )
2293
+ }
2294
+
2295
+ // No `Display` on result of `join()`
2296
+ join. drain ( ..) . map ( |join| join. join ( ) . unwrap ( ) ) . count ( ) ;
2297
+ }
2298
+ }
2299
+
2279
2300
#[ test]
2280
2301
fn recursive_mkdir_slash ( ) {
2281
2302
check ! ( fs:: create_dir_all( & Path :: new( "/" ) ) ) ;
You can’t perform that action at this time.
0 commit comments