@@ -115,21 +115,7 @@ impl CrateSource {
115
115
// url to download the crate from crates.io
116
116
let url = format ! ( "https://crates.io/api/v1/crates/{}/{}/download" , name, version) ;
117
117
println ! ( "Downloading and extracting {} {} from {}" , name, version, url) ;
118
- std:: fs:: create_dir ( "target/lintcheck/" ) . unwrap_or_else ( |err| {
119
- if err. kind ( ) != ErrorKind :: AlreadyExists {
120
- panic ! ( "cannot create lintcheck target dir" ) ;
121
- }
122
- } ) ;
123
- std:: fs:: create_dir ( & krate_download_dir) . unwrap_or_else ( |err| {
124
- if err. kind ( ) != ErrorKind :: AlreadyExists {
125
- panic ! ( "cannot create crate download dir" ) ;
126
- }
127
- } ) ;
128
- std:: fs:: create_dir ( & extract_dir) . unwrap_or_else ( |err| {
129
- if err. kind ( ) != ErrorKind :: AlreadyExists {
130
- panic ! ( "cannot create crate extraction dir" ) ;
131
- }
132
- } ) ;
118
+ create_dirs ( & krate_download_dir, & extract_dir) ;
133
119
134
120
let krate_file_path = krate_download_dir. join ( format ! ( "{}-{}.crate.tar.gz" , name, version) ) ;
135
121
// don't download/extract if we already have done so
@@ -750,6 +736,29 @@ fn print_stats(old_stats: HashMap<String, usize>, new_stats: HashMap<&String, us
750
736
} ) ;
751
737
}
752
738
739
+ /// Create necessary directories to run the lintcheck tool.
740
+ ///
741
+ /// # Panics
742
+ ///
743
+ /// This function panics if creating one of the dirs fails.
744
+ fn create_dirs ( krate_download_dir : & Path , extract_dir : & Path ) {
745
+ std:: fs:: create_dir ( "target/lintcheck/" ) . unwrap_or_else ( |err| {
746
+ if err. kind ( ) != ErrorKind :: AlreadyExists {
747
+ panic ! ( "cannot create lintcheck target dir" ) ;
748
+ }
749
+ } ) ;
750
+ std:: fs:: create_dir ( & krate_download_dir) . unwrap_or_else ( |err| {
751
+ if err. kind ( ) != ErrorKind :: AlreadyExists {
752
+ panic ! ( "cannot create crate download dir" ) ;
753
+ }
754
+ } ) ;
755
+ std:: fs:: create_dir ( & extract_dir) . unwrap_or_else ( |err| {
756
+ if err. kind ( ) != ErrorKind :: AlreadyExists {
757
+ panic ! ( "cannot create crate extraction dir" ) ;
758
+ }
759
+ } ) ;
760
+ }
761
+
753
762
#[ test]
754
763
fn lintcheck_test ( ) {
755
764
let args = [
0 commit comments