@@ -5,7 +5,7 @@ use std::os::unix::process::ExitStatusExt;
5
5
use std:: {
6
6
cmp:: min,
7
7
env, fs,
8
- fs:: File ,
8
+ fs:: { create_dir_all , File } ,
9
9
io:: { BufRead , BufReader , BufWriter , Read , Write } ,
10
10
path:: { Path , PathBuf } ,
11
11
str,
@@ -724,30 +724,6 @@ pub fn range(start: Idx, end: Idx, len: Idx, index: Idx) -> Result<(usize, usize
724
724
}
725
725
}
726
726
727
- /// Create a directory recursively, avoiding the race conditions fixed by
728
- /// https://github.com/rust-lang/rust/pull/39799.
729
- #[ cfg( any( feature = "feature_capable" , feature = "lite" ) ) ]
730
- fn create_dir_all_threadsafe ( path : & Path ) -> std:: io:: Result < ( ) > {
731
- use std:: thread;
732
-
733
- // Try 20 times. This shouldn't theoretically need to be any larger
734
- // than the number of nested directories we need to create.
735
- for _ in 0 ..20 {
736
- match fs:: create_dir_all ( path) {
737
- // This happens if a directory in `path` doesn't exist when we
738
- // test for it, and another thread creates it before we can.
739
- Err ( ref err) if err. kind ( ) == std:: io:: ErrorKind :: AlreadyExists => { } ,
740
- other => return other,
741
- }
742
- // We probably don't need to sleep at all, because the intermediate
743
- // directory is already created. But let's attempt to back off a
744
- // bit and let the other thread finish.
745
- thread:: sleep ( std:: time:: Duration :: from_millis ( 25 ) ) ;
746
- }
747
- // Try one last time, returning whatever happens.
748
- fs:: create_dir_all ( path)
749
- }
750
-
751
727
/// Represents a filename template of the form `"{}.csv"`, where `"{}"` is
752
728
/// the place to insert the part of the filename generated by `qsv`.
753
729
#[ cfg( any( feature = "feature_capable" , feature = "lite" ) ) ]
@@ -783,7 +759,7 @@ impl FilenameTemplate {
783
759
// We may be called concurrently, especially by parallel `qsv
784
760
// split`, so be careful to avoid the `create_dir_all` race
785
761
// condition.
786
- create_dir_all_threadsafe ( parent) ?;
762
+ create_dir_all ( parent) ?;
787
763
}
788
764
let spath = Some ( full_path. display ( ) . to_string ( ) ) ;
789
765
Config :: new ( spath. as_ref ( ) ) . writer ( )
0 commit comments