@@ -28,7 +28,7 @@ use path_slash::*;
2828pub ( crate ) use path_transformer:: PathTransformers ;
2929use pna:: {
3030 Archive , EntryBuilder , EntryPart , LinkTargetType , MIN_CHUNK_BYTES_SIZE , NormalEntry ,
31- PNA_HEADER , ReadEntry , SolidEntryBuilder , WriteOptions , prelude:: * ,
31+ PNA_HEADER , ReadEntry , ReadOptions , SolidEntryBuilder , WriteOptions , prelude:: * ,
3232} ;
3333use std:: {
3434 borrow:: Cow ,
@@ -1290,7 +1290,7 @@ impl TransformStrategy for TransformStrategyUnSolid {
12901290 {
12911291 match read_entry? {
12921292 ReadEntry :: Solid ( s) => {
1293- for n in s. entries ( password) ? {
1293+ for n in s. entries ( ReadOptions :: with_password ( password) ) ? {
12941294 if let Some ( entry) = transformer ( n. map ( Into :: into) ) ? {
12951295 archive. add_entry ( entry) ?;
12961296 }
@@ -1334,7 +1334,7 @@ impl TransformStrategy for TransformStrategyKeepSolid {
13341334 . password ( password)
13351335 . build ( ) ,
13361336 ) ?;
1337- for n in s. entries ( password) ? {
1337+ for n in s. entries ( ReadOptions :: with_password ( password) ) ? {
13381338 if let Some ( entry) = transformer ( n. map ( Into :: into) ) ? {
13391339 builder. add_entry ( entry) ?;
13401340 }
@@ -1426,43 +1426,39 @@ where
14261426 Ok ( ( ) )
14271427}
14281428
1429- pub ( crate ) fn run_process_archive < ' p , Provider , F > (
1429+ pub ( crate ) fn run_process_archive < F > (
14301430 archive_provider : impl IntoIterator < Item = impl Read > ,
1431- mut password_provider : Provider ,
1431+ read_options : & ReadOptions ,
14321432 mut processor : F ,
14331433 allow_concatenated_archives : bool ,
14341434) -> io:: Result < ( ) >
14351435where
1436- Provider : FnMut ( ) -> Option < & ' p [ u8 ] > ,
14371436 F : FnMut ( io:: Result < NormalEntry > ) -> io:: Result < ( ) > ,
14381437{
1439- let password = password_provider ( ) ;
14401438 run_read_entries (
14411439 archive_provider,
14421440 |entry| match entry? {
1443- ReadEntry :: Solid ( solid) => solid. entries ( password ) ?. try_for_each ( & mut processor) ,
1441+ ReadEntry :: Solid ( solid) => solid. entries ( read_options ) ?. try_for_each ( & mut processor) ,
14441442 ReadEntry :: Normal ( regular) => processor ( Ok ( regular) ) ,
14451443 } ,
14461444 allow_concatenated_archives,
14471445 )
14481446}
14491447
1450- pub ( crate ) fn run_process_archive_stoppable < ' p , Provider , F > (
1448+ pub ( crate ) fn run_process_archive_stoppable < F > (
14511449 archive_provider : impl IntoIterator < Item = impl Read > ,
1452- mut password_provider : Provider ,
1450+ read_options : & ReadOptions ,
14531451 mut processor : F ,
14541452 allow_concatenated_archives : bool ,
14551453) -> io:: Result < ( ) >
14561454where
1457- Provider : FnMut ( ) -> Option < & ' p [ u8 ] > ,
14581455 F : FnMut ( io:: Result < NormalEntry > ) -> io:: Result < ProcessAction > ,
14591456{
1460- let password = password_provider ( ) ;
14611457 run_read_entries_stoppable (
14621458 archive_provider,
14631459 |entry| match entry? {
14641460 ReadEntry :: Solid ( solid) => {
1465- for n in solid. entries ( password ) ? {
1461+ for n in solid. entries ( read_options ) ? {
14661462 match processor ( n) ? {
14671463 ProcessAction :: Continue => { }
14681464 ProcessAction :: Stop => return Ok ( ProcessAction :: Stop ) ,
@@ -1530,21 +1526,19 @@ where
15301526}
15311527
15321528#[ cfg( feature = "memmap" ) ]
1533- pub ( crate ) fn run_entries < ' d , ' p , Provider , F > (
1529+ pub ( crate ) fn run_entries < ' d , F > (
15341530 archives : impl IntoIterator < Item = & ' d [ u8 ] > ,
1535- mut password_provider : Provider ,
1531+ read_options : & ReadOptions ,
15361532 mut processor : F ,
15371533) -> io:: Result < ( ) >
15381534where
1539- Provider : FnMut ( ) -> Option < & ' p [ u8 ] > ,
15401535 F : FnMut ( io:: Result < NormalEntry < Cow < ' d , [ u8 ] > > > ) -> io:: Result < ( ) > ,
15411536{
1542- let password = password_provider ( ) ;
15431537 run_read_entries_mem (
15441538 archives,
15451539 |entry| match entry? {
15461540 ReadEntry :: Solid ( s) => s
1547- . entries ( password ) ?
1541+ . entries ( read_options ) ?
15481542 . try_for_each ( |r| processor ( r. map ( Into :: into) ) ) ,
15491543 ReadEntry :: Normal ( r) => processor ( Ok ( r) ) ,
15501544 } ,
@@ -1615,21 +1609,19 @@ where
16151609}
16161610
16171611#[ cfg( feature = "memmap" ) ]
1618- pub ( crate ) fn run_entries_stoppable < ' d , ' p , Provider , F > (
1612+ pub ( crate ) fn run_entries_stoppable < ' d , F > (
16191613 archives : impl IntoIterator < Item = & ' d [ u8 ] > ,
1620- mut password_provider : Provider ,
1614+ read_options : & ReadOptions ,
16211615 mut processor : F ,
16221616) -> io:: Result < ( ) >
16231617where
1624- Provider : FnMut ( ) -> Option < & ' p [ u8 ] > ,
16251618 F : FnMut ( io:: Result < NormalEntry < Cow < ' d , [ u8 ] > > > ) -> io:: Result < ProcessAction > ,
16261619{
1627- let password = password_provider ( ) ;
16281620 run_read_entries_mem_stoppable (
16291621 archives,
16301622 |entry| match entry? {
16311623 ReadEntry :: Solid ( s) => {
1632- for n in s. entries ( password ) ? {
1624+ for n in s. entries ( read_options ) ? {
16331625 match processor ( n. map ( Into :: into) ) ? {
16341626 ProcessAction :: Continue => { }
16351627 ProcessAction :: Stop => return Ok ( ProcessAction :: Stop ) ,
@@ -1898,9 +1890,10 @@ pub(crate) fn transform_archive_entries<R: io::Read>(
18981890 allow_concatenated_archives : bool ,
18991891) -> io:: Result < Vec < io:: Result < Option < NormalEntry > > > > {
19001892 let mut results = Vec :: new ( ) ;
1893+ let read_options = ReadOptions :: with_password ( password) ;
19011894 run_process_archive (
19021895 std:: iter:: once ( reader) ,
1903- || password ,
1896+ & read_options ,
19041897 |entry| {
19051898 let entry = entry?;
19061899 if filter. excluded ( entry. header ( ) . path ( ) ) {
0 commit comments