@@ -34,7 +34,7 @@ pub mod varlink;
3434
3535#[ cfg( any( feature = "oci" , feature = "http" ) ) ]
3636use std:: collections:: HashMap ;
37- use std:: io:: Read ;
37+ use std:: io:: { Read , Write } ;
3838use std:: path:: Path ;
3939#[ cfg( any( feature = "oci" , feature = "http" ) ) ]
4040use std:: sync:: Mutex ;
@@ -1531,7 +1531,7 @@ pub fn dump_files<ObjectID: FsVerityHashValue>(
15311531 image_name : & str ,
15321532 files : & Vec < PathBuf > ,
15331533 backing_path_only : bool ,
1534- ) -> Result < ( ) > {
1534+ ) -> Result < Vec < u8 > > {
15351535 let ( img_fd, _) = repo. open_image ( image_name) ?;
15361536
15371537 let mut img_buf = Vec :: new ( ) ;
@@ -1567,13 +1567,20 @@ pub fn dump_files<ObjectID: FsVerityHashValue>(
15671567 let leaf = fs. leaf ( * leaf_id) ;
15681568 match & leaf. content {
15691569 Regular ( f) => match f {
1570- Inline ( ..) | Sparse ( ..) => println ! ( "{} inline" , file_path. display( ) ) ,
1570+ Inline ( ..) | Sparse ( ..) => {
1571+ writeln ! ( & mut out, "{} inline" , file_path. display( ) ) ?;
1572+ }
15711573 External ( id, _) | ExternalNoVerity ( id, _) => {
1572- println ! ( "{} {}" , file_path. display( ) , id. to_object_pathname( ) ) ;
1574+ writeln ! (
1575+ & mut out,
1576+ "{} {}" ,
1577+ file_path. display( ) ,
1578+ id. to_object_pathname( )
1579+ ) ?;
15731580 }
15741581 } ,
15751582 _ => {
1576- println ! ( "{} inline" , file_path. display( ) )
1583+ writeln ! ( & mut out , "{} inline" , file_path. display( ) ) ? ;
15771584 }
15781585 }
15791586
@@ -1585,12 +1592,7 @@ pub fn dump_files<ObjectID: FsVerityHashValue>(
15851592 } ;
15861593 }
15871594
1588- if !out. is_empty ( ) {
1589- let out_str = std:: str:: from_utf8 ( & out) . unwrap ( ) ;
1590- println ! ( "{}" , out_str) ;
1591- }
1592-
1593- Ok ( ( ) )
1595+ Ok ( out)
15941596}
15951597
15961598/// Run commands that don't require a repository.
@@ -2281,7 +2283,12 @@ where
22812283 files,
22822284 backing_path_only,
22832285 } => {
2284- dump_files ( & repo, & image_name, & files, backing_path_only) ?;
2286+ let out = dump_files ( & repo, & image_name, & files, backing_path_only) ?;
2287+
2288+ if !out. is_empty ( ) {
2289+ let out_str = std:: str:: from_utf8 ( & out) . unwrap ( ) ;
2290+ print ! ( "{}" , out_str) ;
2291+ }
22852292 }
22862293 Command :: Fsck {
22872294 json,
0 commit comments