@@ -1445,19 +1445,17 @@ pub fn archive(paths: &ExePaths, quiet: bool, cpus: usize, password: &str, exlud
14451445 let output_folder_obj = output_folder_obj. parent ( ) . unwrap ( ) ;
14461446 let output_folder = output_folder_obj. to_str ( ) . unwrap ( ) ;
14471447
1448- let mut cmd = vec ! [ paths. zip_path. as_str( ) , "-r" ] ;
1448+ let password_arg = format ! ( "-p{}" , create_cli_string( & password) ) ;
1449+ let thread_arg = format ! ( "-mmt{}" , threads) ;
1450+
1451+ let mut cmd = vec ! [ paths. p7z_path. as_str( ) , "a" , "-tzip" , "-aoa" , thread_arg. as_str( ) ] ;
14491452
14501453 if best_compression {
1451- cmd. push ( "-9 " ) ;
1454+ cmd. push ( "-mx " ) ;
14521455 }
14531456
14541457 if !password. is_empty ( ) {
1455- cmd. push ( "--password" ) ;
1456- cmd. push ( password) ;
1457- }
1458-
1459- if quiet {
1460- cmd. push ( "-q" ) ;
1458+ cmd. push ( password_arg. as_str ( ) ) ;
14611459 }
14621460
14631461 output_path_obj = if let Some ( _) = & split {
@@ -1476,40 +1474,36 @@ pub fn archive(paths: &ExePaths, quiet: bool, cpus: usize, password: &str, exlud
14761474
14771475 cmd. push ( output_path_obj. to_str ( ) . unwrap ( ) ) ;
14781476
1477+ for input_path in input_paths {
1478+ cmd. push ( input_path) ;
1479+ }
1480+
14791481 if output_path_obj. exists ( ) {
1480- if let Err ( error) = fs:: remove_file ( output_path ) {
1482+ if let Err ( error) = fs:: remove_file ( output_path_obj . to_str ( ) . unwrap ( ) ) {
14811483 return Err ( error. to_string ( ) ) ;
14821484 }
14831485 }
14841486
1485- let mut es = 0 ;
1486-
1487- for input_path in input_paths {
1488- let input_path_obj = Path :: new ( input_path) ;
1489- let file_name = Path :: file_name ( input_path_obj) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
1490-
1491- let mut cmd = cmd. clone ( ) ;
1492-
1493- cmd. push ( file_name) ;
1494-
1495- let input_folder = input_path_obj. parent ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
1487+ let result = if quiet {
1488+ execute_one_quiet ( & cmd, output_folder)
1489+ } else {
1490+ execute_one ( & cmd, output_folder)
1491+ } ;
14961492
1497- es = match execute_one ( & cmd, input_folder) {
1493+ if let Some ( byte) = split {
1494+ match result {
14981495 Ok ( es) => {
14991496 if es != 0 {
15001497 try_delete_file ( output_path) ;
15011498 return Ok ( es) ;
15021499 }
1503- es
15041500 }
15051501 Err ( error) => {
15061502 try_delete_file ( output_path) ;
15071503 return Err ( error) ;
15081504 }
15091505 }
1510- }
15111506
1512- if let Some ( byte) = split {
15131507 let mut volume = String :: from ( "" ) ;
15141508 let new_output_path_obj;
15151509
@@ -1534,6 +1528,7 @@ pub fn archive(paths: &ExePaths, quiet: bool, cpus: usize, password: &str, exlud
15341528 } else {
15351529 volume. push_str ( format ! ( "{}k" , byte. get_adjusted_unit( ByteUnit :: KiB ) . get_value( ) . round( ) as u32 ) . as_str ( ) ) ;
15361530 }
1531+
15371532 cmd. push ( & volume) ;
15381533
15391534 cmd. push ( output_path_obj. to_str ( ) . unwrap ( ) ) ;
@@ -1548,10 +1543,10 @@ pub fn archive(paths: &ExePaths, quiet: bool, cpus: usize, password: &str, exlud
15481543
15491544 cmd. push ( new_output_path) ;
15501545
1551- es = match execute_one ( & cmd, output_folder) {
1546+ match execute_one ( & cmd, output_folder) {
15521547 Ok ( es) => {
15531548 try_delete_file ( output_path) ;
1554- es
1549+ return Ok ( es ) ;
15551550 }
15561551 Err ( error) => {
15571552 try_delete_file ( output_path) ;
@@ -1561,7 +1556,7 @@ pub fn archive(paths: &ExePaths, quiet: bool, cpus: usize, password: &str, exlud
15611556 }
15621557 }
15631558
1564- Ok ( es )
1559+ result
15651560 }
15661561 ArchiveFormat :: Rar => {
15671562 let password_arg = format ! ( "-hp{}" , create_cli_string( & password) ) ;
0 commit comments