@@ -19,7 +19,8 @@ use zip::ZipArchive;
1919#[ allow( clippy:: case_sensitive_file_extension_comparisons) ]
2020#[ allow( clippy:: cast_precision_loss) ]
2121#[ instrument( skip( bytes) ) ]
22- pub fn extract ( bytes : & Vec < u8 > , out_dir : & Path ) -> Result < ( ) > {
22+ pub fn extract ( bytes : & Vec < u8 > , out_dir : & Path ) -> Result < Vec < PathBuf > > {
23+ let mut files = Vec :: new ( ) ;
2324 let parent_dir = if let Some ( parent) = out_dir. parent ( ) {
2425 parent
2526 } else {
@@ -38,7 +39,7 @@ pub fn extract(bytes: &Vec<u8>, out_dir: &Path) -> Result<()> {
3839 out_dir. to_string_lossy( )
3940 ) ;
4041 remove_file ( & lock_file) ?;
41- return Ok ( ( ) ) ;
42+ return Ok ( files ) ;
4243 }
4344
4445 let extract_dir = tempfile:: tempdir_in ( parent_dir) ?. into_path ( ) ;
@@ -66,7 +67,6 @@ pub fn extract(bytes: &Vec<u8>, out_dir: &Path) -> Result<()> {
6667 let input = BufReader :: new ( Cursor :: new ( archive_bytes) ) ;
6768 let decoder = XzDecoder :: new ( input) ;
6869 let mut archive = Archive :: new ( decoder) ;
69- let mut files = 0 ;
7070 let mut extracted_bytes = 0 ;
7171
7272 for archive_entry in archive. entries ( ) ? {
@@ -92,20 +92,20 @@ pub fn extract(bytes: &Vec<u8>, out_dir: &Path) -> Result<()> {
9292 } else if entry_type. is_file ( ) {
9393 let mut output_file = File :: create ( & entry_name) ?;
9494 copy ( & mut entry, & mut output_file) ?;
95-
96- files += 1 ;
9795 extracted_bytes += entry_size;
9896
9997 #[ cfg( unix) ]
10098 {
10199 use std:: os:: unix:: fs:: PermissionsExt ;
102100 output_file. set_permissions ( std:: fs:: Permissions :: from_mode ( file_mode) ) ?;
103101 }
102+ files. push ( entry_name) ;
104103 } else if entry_type. is_symlink ( ) {
105104 #[ cfg( unix) ]
106105 if let Some ( symlink_target) = entry. link_name ( ) ? {
107- let symlink_path = entry_name;
106+ let symlink_path = entry_name. clone ( ) ;
108107 std:: os:: unix:: fs:: symlink ( symlink_target. as_ref ( ) , symlink_path) ?;
108+ files. push ( entry_name) ;
109109 }
110110 }
111111 }
@@ -131,13 +131,14 @@ pub fn extract(bytes: &Vec<u8>, out_dir: &Path) -> Result<()> {
131131 remove_file ( lock_file) ?;
132132 }
133133
134+ let number_of_files = files. len ( ) ;
134135 debug ! (
135136 "Extracting {} files totalling {}" ,
136- files . to_formatted_string( & Locale :: en) ,
137+ number_of_files . to_formatted_string( & Locale :: en) ,
137138 human_bytes( extracted_bytes as f64 )
138139 ) ;
139140
140- Ok ( ( ) )
141+ Ok ( files )
141142}
142143
143144/// Acquires a lock file in the [out_dir](Path) to prevent multiple processes from extracting the
0 commit comments