File tree 4 files changed +4
-4
lines changed
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(
18
18
password : Option < & [ u8 ] > ,
19
19
quiet : bool ,
20
20
) -> 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 ( ) ) ;
22
22
23
23
let archive = match password {
24
24
Some ( password) => Archive :: with_password ( archive_path, password) ,
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ use crate::{
24
24
/// Unpacks the archive given by `archive` into the folder given by `into`.
25
25
/// Assumes that output_folder is empty
26
26
pub 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 ( ) ) ;
28
28
let mut archive = tar:: Archive :: new ( reader) ;
29
29
30
30
let mut files_unpacked = 0 ;
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ pub fn unpack_archive<R>(
37
37
where
38
38
R : Read + Seek ,
39
39
{
40
- assert ! ( output_folder. read_dir( ) . expect( "dir exists" ) . count ( ) == 0 ) ;
40
+ assert ! ( output_folder. read_dir( ) . expect( "dir exists" ) . next ( ) . is_none ( ) ) ;
41
41
42
42
let mut unpacked_files = 0 ;
43
43
Original file line number Diff line number Diff line change @@ -356,7 +356,7 @@ fn smart_unpack(
356
356
357
357
let files = unpack_fn ( temp_dir_path) ?;
358
358
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 ;
360
360
361
361
let ( previous_path, mut new_path) = if root_contains_only_one_element {
362
362
// 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