Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 3 additions & 6 deletions src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ use tracing_subscriber::{EnvFilter, Registry, reload::Handle};
use crate::{
cli::download_tracker::DownloadTracker,
config::Cfg,
dist::{TargetTriple, ToolchainDesc, notifications as dist_notifications},
dist::{TargetTriple, ToolchainDesc},
errors::RustupError,
install::UpdateStatus,
notifications::Notification,
process::{Process, terminalsource},
toolchain::{LocalToolchainName, Toolchain, ToolchainName},
utils::{self, notifications as util_notifications, notify::NotificationLevel},
utils::{self, notify::NotificationLevel},
};

pub(crate) const WARN_COMPLETE_PROFILE: &str = "downloading with complete profile isn't recommended unless you are a developer of the rust language";
Expand Down Expand Up @@ -139,10 +139,7 @@ impl Notifier {
return;
}

if let Notification::Install(dist_notifications::Notification::Utils(
util_notifications::Notification::SetDefaultBufferSize(_),
)) = &n
{
if let Notification::SetDefaultBufferSize(_) = &n {
if *self.ram_notice_shown.borrow() {
return;
} else {
Expand Down
17 changes: 6 additions & 11 deletions src/cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
use std::collections::HashMap;
use std::time::{Duration, Instant};

use crate::dist::Notification as In;
use crate::notifications::Notification;
use crate::process::Process;
use crate::utils::Notification as Un;

/// Tracks download progress and displays information about it to a terminal.
///
Expand Down Expand Up @@ -40,36 +38,33 @@ impl DownloadTracker {

pub(crate) fn handle_notification(&mut self, n: &Notification<'_>) -> bool {
match *n {
Notification::Install(In::Utils(Un::DownloadContentLengthReceived(
content_len,
url,
))) => {
Notification::DownloadContentLengthReceived(content_len, url) => {
if let Some(url) = url {
self.content_length_received(content_len, url);
}
true
}
Notification::Install(In::Utils(Un::DownloadDataReceived(data, url))) => {
Notification::DownloadDataReceived(data, url) => {
if let Some(url) = url {
self.data_received(data.len(), url);
}
true
}
Notification::Install(In::Utils(Un::DownloadFinished(url))) => {
Notification::DownloadFinished(url) => {
if let Some(url) = url {
self.download_finished(url);
}
true
}
Notification::Install(In::Utils(Un::DownloadFailed(url))) => {
Notification::DownloadFailed(url) => {
self.download_failed(url);
false
}
Notification::Install(In::DownloadingComponent(component, _, _, url)) => {
Notification::DownloadingComponent(component, _, _, url) => {
self.create_progress_bar(component.to_owned(), url.to_owned());
true
}
Notification::Install(In::RetryingDownload(url)) => {
Notification::RetryingDownload(url) => {
self.retrying_download(url);
true
}
Expand Down
3 changes: 2 additions & 1 deletion src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ use crate::{
dist::{self, PartialToolchainDesc, Profile, TargetTriple, ToolchainDesc},
errors::RustupError,
install::UpdateStatus,
notifications::Notification,
process::{Process, terminalsource},
toolchain::{
DistributableToolchain, MaybeOfficialToolchainName, ResolvableToolchainName, Toolchain,
ToolchainName,
},
utils::{self, Notification},
utils,
};

#[cfg(unix)]
Expand Down
3 changes: 2 additions & 1 deletion src/cli/self_update/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use tracing::{error, warn};

use super::install_bins;
use super::shell::{self, Posix, UnixShell};
use crate::notifications::Notification;
use crate::process::Process;
use crate::utils::{self, Notification};
use crate::utils;

// If the user is trying to install with sudo, on some systems this will
// result in writing root-owned files to the user's home directory, because
Expand Down
7 changes: 3 additions & 4 deletions src/cli/self_update/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ use super::{InstallOpts, install_bins, report_error};
use crate::cli::{download_tracker::DownloadTracker, markdown::md};
use crate::dist::TargetTriple;
use crate::download::download_file;
use crate::notifications::Notification;
use crate::process::{Process, terminalsource::ColorableTerminal};
use crate::utils::{self, Notification};
use crate::utils;

pub(crate) fn ensure_prompt(process: &Process) -> Result<()> {
writeln!(process.stdout().lock(),)?;
Expand Down Expand Up @@ -285,9 +286,7 @@ pub(crate) async fn try_install_msvc(
&visual_studio,
None,
&move |n| {
download_tracker.lock().unwrap().handle_notification(
&crate::notifications::Notification::Install(crate::dist::Notification::Utils(n)),
);
download_tracker.lock().unwrap().handle_notification(&n);
},
process,
)
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl<'a> Cfg<'a> {
let tmp_cx = temp::Context::new(
rustup_dir.join("tmp"),
dist_root_server.as_str(),
Box::new(move |n| (notify_clone)(n.into())),
Box::new(move |n| (notify_clone)(n)),
);
let dist_root = dist_root_server + "/dist";

Expand Down Expand Up @@ -330,7 +330,7 @@ impl<'a> Cfg<'a> {
/// construct a download configuration
pub(crate) fn download_cfg(
&'a self,
notify_handler: &'a dyn Fn(crate::dist::Notification<'_>),
notify_handler: &'a dyn Fn(Notification<'_>),
) -> DownloadCfg<'a> {
DownloadCfg {
dist_root: &self.dist_root_url,
Expand Down
2 changes: 1 addition & 1 deletion src/diskio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ use std::{fmt::Debug, fs::OpenOptions};

use anyhow::Result;

use crate::notifications::Notification;
use crate::process::Process;
use crate::utils::notifications::Notification;
use threaded::PoolReference;

/// Carries the implementation specific data for complete file transfers into the executor.
Expand Down
2 changes: 1 addition & 1 deletion src/diskio/threaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use sharded_slab::pool::{OwnedRef, OwnedRefMut};
use tracing::debug;

use super::{CompletedIo, Executor, Item, perform};
use crate::utils::notifications::Notification;
use crate::notifications::Notification;

#[derive(Copy, Clone, Debug, Enum)]
pub(crate) enum Bucket {
Expand Down
3 changes: 2 additions & 1 deletion src/dist/component/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ use crate::dist::component::components::*;
use crate::dist::component::transaction::*;
use crate::dist::temp;
use crate::errors::*;
use crate::notifications::Notification;
use crate::process::Process;
use crate::utils::{self, Notification};
use crate::utils;

/// The current metadata revision used by rust-installer
pub(crate) const INSTALLER_VERSION: &str = "3";
Expand Down
Loading
Loading