@@ -16,10 +16,9 @@ use tracing::{error, trace, warn};
1616use crate :: diskio:: { CompletedIo , Executor , FileBuffer , IO_CHUNK_SIZE , Item , Kind , get_executor} ;
1717use crate :: dist:: component:: components:: * ;
1818use crate :: dist:: component:: transaction:: * ;
19- use crate :: dist:: download:: Notifier ;
19+ use crate :: dist:: download:: DownloadCfg ;
2020use crate :: dist:: temp;
2121use crate :: errors:: * ;
22- use crate :: process:: Process ;
2322use crate :: utils;
2423use crate :: utils:: units:: Size ;
2524
@@ -143,13 +142,13 @@ impl Package for DirectoryPackage {
143142pub ( crate ) struct TarPackage ( DirectoryPackage , temp:: Dir ) ;
144143
145144impl TarPackage {
146- pub ( crate ) fn new < R : Read > ( stream : R , cx : & PackageContext < ' _ > ) -> Result < Self > {
147- let temp_dir = cx . tmp_cx . new_directory ( ) ?;
145+ pub ( crate ) fn new < R : Read > ( stream : R , dl_cfg : & DownloadCfg < ' _ > ) -> Result < Self > {
146+ let temp_dir = dl_cfg . tmp_cx . new_directory ( ) ?;
148147 let mut archive = tar:: Archive :: new ( stream) ;
149148 // The rust-installer packages unpack to a directory called
150149 // $pkgname-$version-$target. Skip that directory when
151150 // unpacking.
152- unpack_without_first_dir ( & mut archive, & temp_dir, cx )
151+ unpack_without_first_dir ( & mut archive, & temp_dir, dl_cfg )
153152 . context ( "failed to extract package" ) ?;
154153
155154 Ok ( TarPackage (
@@ -163,7 +162,7 @@ impl TarPackage {
163162fn unpack_ram (
164163 io_chunk_size : usize ,
165164 effective_max_ram : Option < usize > ,
166- cx : & PackageContext < ' _ > ,
165+ dl_cfg : & DownloadCfg < ' _ > ,
167166) -> usize {
168167 const RAM_ALLOWANCE_FOR_RUSTUP_AND_BUFFERS : usize = 200 * 1024 * 1024 ;
169168 let minimum_ram = io_chunk_size * 2 ;
@@ -177,7 +176,7 @@ fn unpack_ram(
177176 // Rustup does not know how much RAM the machine has: use the minimum
178177 minimum_ram
179178 } ;
180- let unpack_ram = match cx
179+ let unpack_ram = match dl_cfg
181180 . process
182181 . var ( "RUSTUP_UNPACK_RAM" )
183182 . ok ( )
@@ -289,7 +288,7 @@ enum DirStatus {
289288fn unpack_without_first_dir < R : Read > (
290289 archive : & mut tar:: Archive < R > ,
291290 path : & Path ,
292- cx : & PackageContext < ' _ > ,
291+ dl_cfg : & DownloadCfg < ' _ > ,
293292) -> Result < ( ) > {
294293 let entries = archive. entries ( ) ?;
295294 let effective_max_ram = match effective_limits:: memory_limit ( ) {
@@ -299,8 +298,9 @@ fn unpack_without_first_dir<R: Read>(
299298 None
300299 }
301300 } ;
302- let unpack_ram = unpack_ram ( IO_CHUNK_SIZE , effective_max_ram, cx) ;
303- let mut io_executor: Box < dyn Executor > = get_executor ( cx. notifier , unpack_ram, cx. process ) ?;
301+ let unpack_ram = unpack_ram ( IO_CHUNK_SIZE , effective_max_ram, dl_cfg) ;
302+ let mut io_executor: Box < dyn Executor > =
303+ get_executor ( Some ( & dl_cfg. notifier ) , unpack_ram, dl_cfg. process ) ?;
304304
305305 let mut directories: HashMap < PathBuf , DirStatus > = HashMap :: new ( ) ;
306306 // Path is presumed to exist. Call it a precondition.
@@ -461,7 +461,7 @@ fn unpack_without_first_dir<R: Read>(
461461 // Complain about this so we can see if these exist.
462462 use std:: io:: Write as _;
463463 writeln ! (
464- cx . process. stderr( ) . lock( ) ,
464+ dl_cfg . process. stderr( ) . lock( ) ,
465465 "Unexpected: missing parent '{}' for '{}'" ,
466466 parent. display( ) ,
467467 entry. path( ) ?. display( )
@@ -552,9 +552,9 @@ impl Package for TarPackage {
552552pub ( crate ) struct TarGzPackage ( TarPackage ) ;
553553
554554impl TarGzPackage {
555- pub ( crate ) fn new < R : Read > ( stream : R , cx : & PackageContext < ' _ > ) -> Result < Self > {
555+ pub ( crate ) fn new < R : Read > ( stream : R , dl_cfg : & DownloadCfg < ' _ > ) -> Result < Self > {
556556 let stream = flate2:: read:: GzDecoder :: new ( stream) ;
557- Ok ( TarGzPackage ( TarPackage :: new ( stream, cx ) ?) )
557+ Ok ( TarGzPackage ( TarPackage :: new ( stream, dl_cfg ) ?) )
558558 }
559559}
560560
@@ -580,9 +580,9 @@ impl Package for TarGzPackage {
580580pub ( crate ) struct TarXzPackage ( TarPackage ) ;
581581
582582impl TarXzPackage {
583- pub ( crate ) fn new < R : Read > ( stream : R , cx : & PackageContext < ' _ > ) -> Result < Self > {
583+ pub ( crate ) fn new < R : Read > ( stream : R , dl_cfg : & DownloadCfg < ' _ > ) -> Result < Self > {
584584 let stream = xz2:: read:: XzDecoder :: new ( stream) ;
585- Ok ( TarXzPackage ( TarPackage :: new ( stream, cx ) ?) )
585+ Ok ( TarXzPackage ( TarPackage :: new ( stream, dl_cfg ) ?) )
586586 }
587587}
588588
@@ -608,9 +608,9 @@ impl Package for TarXzPackage {
608608pub ( crate ) struct TarZStdPackage ( TarPackage ) ;
609609
610610impl TarZStdPackage {
611- pub ( crate ) fn new < R : Read > ( stream : R , cx : & PackageContext < ' _ > ) -> Result < Self > {
611+ pub ( crate ) fn new < R : Read > ( stream : R , dl_cfg : & DownloadCfg < ' _ > ) -> Result < Self > {
612612 let stream = zstd:: stream:: read:: Decoder :: new ( stream) ?;
613- Ok ( TarZStdPackage ( TarPackage :: new ( stream, cx ) ?) )
613+ Ok ( TarZStdPackage ( TarPackage :: new ( stream, dl_cfg ) ?) )
614614 }
615615}
616616
@@ -631,9 +631,3 @@ impl Package for TarZStdPackage {
631631 self . 0 . components ( )
632632 }
633633}
634-
635- pub ( crate ) struct PackageContext < ' a > {
636- pub ( crate ) tmp_cx : & ' a temp:: Context ,
637- pub ( crate ) notifier : Option < & ' a Notifier > ,
638- pub ( crate ) process : & ' a Process ,
639- }
0 commit comments