File tree Expand file tree Collapse file tree 4 files changed +4
-4
lines changed
Expand file tree Collapse file tree 4 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ pub fn unpack_archive(
1818 password : Option < & [ u8 ] > ,
1919 quiet : bool ,
2020) -> crate :: Result < usize > {
21- assert ! ( output_folder. read_dir( ) . expect( "dir exists" ) . count ( ) == 0 ) ;
21+ assert ! ( output_folder. read_dir( ) . expect( "dir exists" ) . next ( ) . is_none ( ) ) ;
2222
2323 let archive = match password {
2424 Some ( password) => Archive :: with_password ( archive_path, password) ,
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ use crate::{
2424/// Unpacks the archive given by `archive` into the folder given by `into`.
2525/// Assumes that output_folder is empty
2626pub fn unpack_archive ( reader : Box < dyn Read > , output_folder : & Path , quiet : bool ) -> crate :: Result < usize > {
27- assert ! ( output_folder. read_dir( ) . expect( "dir exists" ) . count ( ) == 0 ) ;
27+ assert ! ( output_folder. read_dir( ) . expect( "dir exists" ) . next ( ) . is_none ( ) ) ;
2828 let mut archive = tar:: Archive :: new ( reader) ;
2929
3030 let mut files_unpacked = 0 ;
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ pub fn unpack_archive<R>(
3737where
3838 R : Read + Seek ,
3939{
40- assert ! ( output_folder. read_dir( ) . expect( "dir exists" ) . count ( ) == 0 ) ;
40+ assert ! ( output_folder. read_dir( ) . expect( "dir exists" ) . next ( ) . is_none ( ) ) ;
4141
4242 let mut unpacked_files = 0 ;
4343
Original file line number Diff line number Diff line change @@ -356,7 +356,7 @@ fn smart_unpack(
356356
357357 let files = unpack_fn ( temp_dir_path) ?;
358358
359- let root_contains_only_one_element = fs:: read_dir ( temp_dir_path) ?. count ( ) == 1 ;
359+ let root_contains_only_one_element = fs:: read_dir ( temp_dir_path) ?. take ( 2 ) . count ( ) == 1 ;
360360
361361 let ( previous_path, mut new_path) = if root_contains_only_one_element {
362362 // Only one file in the root directory, so we can just move it to the output directory
You can’t perform that action at this time.
0 commit comments