Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename temp::Cfg to temp::Context #3761

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ fn update(cfg: &mut Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
common::update_all_channels(cfg, self_update, m.get_flag("force"))?;
info!("cleaning up downloads & tmp directories");
utils::delete_dir_contents_following_links(&cfg.download_dir);
cfg.temp_cfg.clean();
cfg.tmp_cx.clean();
}

if !self_update::NEVER_SELF_UPDATE && self_update_mode == SelfUpdateMode::CheckOnly {
Expand Down
10 changes: 5 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub(crate) struct Cfg {
pub toolchains_dir: PathBuf,
pub update_hash_dir: PathBuf,
pub download_dir: PathBuf,
pub temp_cfg: temp::Cfg,
pub tmp_cx: temp::Context,
pub toolchain_override: Option<ResolvableToolchainName>,
pub env_override: Option<LocalToolchainName>,
pub dist_root_url: String,
Expand Down Expand Up @@ -241,7 +241,7 @@ impl Cfg {
};

let notify_clone = notify_handler.clone();
let temp_cfg = temp::Cfg::new(
let tmp_cx = temp::Context::new(
rustup_dir.join("tmp"),
dist_root_server.as_str(),
Box::new(move |n| (notify_clone)(n.into())),
Expand All @@ -256,7 +256,7 @@ impl Cfg {
toolchains_dir,
update_hash_dir,
download_dir,
temp_cfg,
tmp_cx,
notify_handler,
toolchain_override: None,
env_override,
Expand All @@ -281,7 +281,7 @@ impl Cfg {
) -> DownloadCfg<'a> {
DownloadCfg {
dist_root: &self.dist_root_url,
temp_cfg: &self.temp_cfg,
tmp_cx: &self.tmp_cx,
download_dir: &self.download_dir,
notify_handler,
}
Expand Down Expand Up @@ -961,7 +961,7 @@ impl Debug for Cfg {
.field("toolchains_dir", &self.toolchains_dir)
.field("update_hash_dir", &self.update_hash_dir)
.field("download_dir", &self.download_dir)
.field("temp_cfg", &self.temp_cfg)
.field("tmp_cx", &self.tmp_cx)
.field("toolchain_override", &self.toolchain_override)
.field("env_override", &self.env_override)
.field("dist_root_url", &self.dist_root_url)
Expand Down
16 changes: 8 additions & 8 deletions src/dist/component/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ pub(crate) struct TarPackage<'a>(DirectoryPackage, temp::Dir<'a>);
impl<'a> TarPackage<'a> {
pub(crate) fn new<R: Read>(
stream: R,
temp_cfg: &'a temp::Cfg,
tmp_cx: &'a temp::Context,
notify_handler: Option<&'a dyn Fn(Notification<'_>)>,
) -> Result<Self> {
let temp_dir = temp_cfg.new_directory()?;
let temp_dir = tmp_cx.new_directory()?;
let mut archive = tar::Archive::new(stream);
// The rust-installer packages unpack to a directory called
// $pkgname-$version-$target. Skip that directory when
Expand Down Expand Up @@ -555,13 +555,13 @@ pub(crate) struct TarGzPackage<'a>(TarPackage<'a>);
impl<'a> TarGzPackage<'a> {
pub(crate) fn new<R: Read>(
stream: R,
temp_cfg: &'a temp::Cfg,
tmp_cx: &'a temp::Context,
notify_handler: Option<&'a dyn Fn(Notification<'_>)>,
) -> Result<Self> {
let stream = flate2::read::GzDecoder::new(stream);
Ok(TarGzPackage(TarPackage::new(
stream,
temp_cfg,
tmp_cx,
notify_handler,
)?))
}
Expand Down Expand Up @@ -591,13 +591,13 @@ pub(crate) struct TarXzPackage<'a>(TarPackage<'a>);
impl<'a> TarXzPackage<'a> {
pub(crate) fn new<R: Read>(
stream: R,
temp_cfg: &'a temp::Cfg,
tmp_cx: &'a temp::Context,
notify_handler: Option<&'a dyn Fn(Notification<'_>)>,
) -> Result<Self> {
let stream = xz2::read::XzDecoder::new(stream);
Ok(TarXzPackage(TarPackage::new(
stream,
temp_cfg,
tmp_cx,
notify_handler,
)?))
}
Expand Down Expand Up @@ -627,13 +627,13 @@ pub(crate) struct TarZStdPackage<'a>(TarPackage<'a>);
impl<'a> TarZStdPackage<'a> {
pub(crate) fn new<R: Read>(
stream: R,
temp_cfg: &'a temp::Cfg,
tmp_cx: &'a temp::Context,
notify_handler: Option<&'a dyn Fn(Notification<'_>)>,
) -> Result<Self> {
let stream = zstd::stream::read::Decoder::new(stream)?;
Ok(TarZStdPackage(TarPackage::new(
stream,
temp_cfg,
tmp_cx,
notify_handler,
)?))
}
Expand Down
Loading
Loading