@@ -14,6 +14,7 @@ use camino::{Utf8Component, Utf8Path, Utf8PathBuf};
14
14
use cap_std:: io_lifetimes;
15
15
use cap_std_ext:: cmdext:: CapStdExtCommandExt ;
16
16
use cap_std_ext:: { cap_std, cap_tempfile} ;
17
+ use fn_error_context:: context;
17
18
use once_cell:: unsync:: OnceCell ;
18
19
use ostree:: gio;
19
20
use ostree:: prelude:: FileExt ;
@@ -31,6 +32,7 @@ use tracing::instrument;
31
32
const EXCLUDED_TOPLEVEL_PATHS : & [ & str ] = & [ "run" , "tmp" , "proc" , "sys" , "dev" ] ;
32
33
33
34
/// Copy a tar entry to a new tar archive, optionally using a different filesystem path.
35
+ #[ context( "Copying entry" ) ]
34
36
pub ( crate ) fn copy_entry (
35
37
entry : tar:: Entry < impl std:: io:: Read > ,
36
38
dest : & mut tar:: Builder < impl std:: io:: Write > ,
@@ -227,18 +229,23 @@ pub(crate) fn filter_tar(
227
229
if is_modified && is_regular {
228
230
tracing:: debug!( "Processing modified sysroot file {path}" ) ;
229
231
// Lazily allocate a temporary directory
230
- let tmpdir = tmpdir. get_or_try_init ( || {
232
+ let tmpdir = tmpdir. get_or_try_init ( || -> anyhow :: Result < _ > {
231
233
let vartmp = & cap_std:: fs:: Dir :: open_ambient_dir (
232
234
"/var/tmp" ,
233
235
cap_std:: ambient_authority ( ) ,
234
- ) ?;
235
- cap_tempfile:: tempdir_in ( vartmp)
236
+ )
237
+ . context ( "Allocating tmpdir" ) ?;
238
+ cap_tempfile:: tempdir_in ( vartmp) . map_err ( anyhow:: Error :: msg)
236
239
} ) ?;
237
240
// Create an O_TMPFILE (anonymous file) to use as a temporary store for the file data
238
- let mut tmpf = cap_tempfile:: TempFile :: new_anonymous ( tmpdir) . map ( BufWriter :: new) ?;
241
+ let mut tmpf = cap_tempfile:: TempFile :: new_anonymous ( tmpdir)
242
+ . map ( BufWriter :: new)
243
+ . context ( "Creating tmpfile" ) ?;
239
244
let path = path. to_owned ( ) ;
240
245
let header = header. clone ( ) ;
241
- std:: io:: copy ( & mut entry, & mut tmpf) ?;
246
+ std:: io:: copy ( & mut entry, & mut tmpf)
247
+ . map_err ( anyhow:: Error :: msg)
248
+ . context ( "Copying" ) ?;
242
249
let mut tmpf = tmpf. into_inner ( ) ?;
243
250
tmpf. seek ( std:: io:: SeekFrom :: Start ( 0 ) ) ?;
244
251
// Cache this data, indexed by the file path
@@ -292,6 +299,7 @@ pub(crate) fn filter_tar(
292
299
}
293
300
294
301
/// Asynchronous wrapper for filter_tar()
302
+ #[ context( "Filtering tar stream" ) ]
295
303
async fn filter_tar_async (
296
304
src : impl AsyncRead + Send + ' static ,
297
305
mut dest : impl AsyncWrite + Send + Unpin ,
@@ -405,7 +413,7 @@ pub async fn write_tar(
405
413
} ;
406
414
tracing:: debug!( "Waiting on child process" ) ;
407
415
let ( filtered_result, child_stdout) =
408
- match tokio:: try_join!( status, filtered_result) . context ( "Processing tar via ostree " ) {
416
+ match tokio:: try_join!( status, filtered_result) . context ( "Processing tar" ) {
409
417
Ok ( ( ( ) , filtered_result) ) => {
410
418
let ( child_stdout, _) = output_copier. await . context ( "Copying child output" ) ?;
411
419
( filtered_result, child_stdout)
0 commit comments