@@ -12,12 +12,9 @@ use anyhow::{Context, Result, anyhow, bail};
1212use tar:: EntryType ;
1313use tracing:: warn;
1414
15- use crate :: diskio:: {
16- CompletedIo , Executor , FileBuffer , IO_CHUNK_SIZE , Item , Kind , get_executor, unpack_ram,
17- } ;
15+ use crate :: diskio:: { CompletedIo , Executor , FileBuffer , IO_CHUNK_SIZE , Item , Kind } ;
1816use crate :: dist:: component:: components:: { ComponentPart , ComponentPartKind , Components } ;
1917use crate :: dist:: component:: transaction:: Transaction ;
20- use crate :: dist:: download:: DownloadCfg ;
2118use crate :: dist:: manifest:: CompressionKind ;
2219use crate :: dist:: temp;
2320use crate :: errors:: RustupError ;
@@ -38,33 +35,36 @@ impl DirectoryPackage<temp::Dir> {
3835 pub ( crate ) fn compressed < R : Read > (
3936 stream : R ,
4037 kind : CompressionKind ,
41- dl_cfg : & DownloadCfg < ' _ > ,
38+ temp_dir : temp:: Dir ,
39+ io_executor : Box < dyn Executor > ,
4240 ) -> Result < Self > {
4341 match kind {
44- CompressionKind :: GZip => Self :: from_tar ( flate2:: read:: GzDecoder :: new ( stream) , dl_cfg) ,
45- CompressionKind :: ZStd => {
46- Self :: from_tar ( zstd:: stream:: read:: Decoder :: new ( stream) ?, dl_cfg)
42+ CompressionKind :: GZip => {
43+ Self :: from_tar ( flate2:: read:: GzDecoder :: new ( stream) , temp_dir, io_executor)
44+ }
45+ CompressionKind :: ZStd => Self :: from_tar (
46+ zstd:: stream:: read:: Decoder :: new ( stream) ?,
47+ temp_dir,
48+ io_executor,
49+ ) ,
50+ CompressionKind :: XZ => {
51+ Self :: from_tar ( xz2:: read:: XzDecoder :: new ( stream) , temp_dir, io_executor)
4752 }
48- CompressionKind :: XZ => Self :: from_tar ( xz2:: read:: XzDecoder :: new ( stream) , dl_cfg) ,
4953 }
5054 }
5155
52- fn from_tar ( stream : impl Read , dl_cfg : & DownloadCfg < ' _ > ) -> Result < Self > {
53- let temp_dir = dl_cfg. tmp_cx . new_directory ( ) ?;
56+ fn from_tar (
57+ stream : impl Read ,
58+ temp_dir : temp:: Dir ,
59+ io_executor : Box < dyn Executor > ,
60+ ) -> Result < Self > {
5461 let mut archive = tar:: Archive :: new ( stream) ;
5562
5663 // The rust-installer packages unpack to a directory called
5764 // $pkgname-$version-$target. Skip that directory when
5865 // unpacking.
59- unpack_without_first_dir (
60- & mut archive,
61- & temp_dir,
62- get_executor (
63- unpack_ram ( IO_CHUNK_SIZE , dl_cfg. process . unpack_ram ( ) ?) ,
64- dl_cfg. process . io_thread_count ( ) ?,
65- ) ,
66- )
67- . context ( "failed to extract package" ) ?;
66+ unpack_without_first_dir ( & mut archive, & temp_dir, io_executor)
67+ . context ( "failed to extract package" ) ?;
6868
6969 Self :: new ( temp_dir, false )
7070 }
0 commit comments