Skip to content

Commit 7365ab7

Browse files
committed
notifications: privatize Notification type
1 parent a1b2ace commit 7365ab7

File tree

4 files changed

+13
-28
lines changed

4 files changed

+13
-28
lines changed

src/dist/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct DownloadCfg<'a> {
2121
pub dist_root: &'a str,
2222
pub tmp_cx: &'a temp::Context,
2323
pub download_dir: &'a PathBuf,
24-
pub notify_handler: &'a dyn Fn(Notification<'_>),
24+
pub(crate) notify_handler: &'a dyn Fn(Notification<'_>),
2525
pub process: &'a Process,
2626
}
2727

src/dist/manifestation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl Manifestation {
315315
}
316316

317317
#[cfg(test)]
318-
pub fn uninstall(
318+
pub(crate) fn uninstall(
319319
&self,
320320
manifest: &Manifest,
321321
tmp_cx: &temp::Context,

src/download/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async fn download_file_(
9696
use sha2::Digest;
9797
use std::cell::RefCell;
9898

99-
notify_handler(Notification::DownloadingFile(url, path));
99+
notify_handler(Notification::DownloadingFile(url));
100100

101101
let hasher = RefCell::new(hasher);
102102

src/notifications.rs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ use crate::utils::units;
1010
use crate::{dist::ToolchainDesc, toolchain::ToolchainName, utils::notify::NotificationLevel};
1111

1212
#[derive(Debug)]
13-
pub enum Notification<'a> {
14-
Extracting(&'a Path, &'a Path),
13+
pub(crate) enum Notification<'a> {
1514
ComponentAlreadyInstalled(&'a str),
1615
CantReadUpdateHash(&'a Path),
1716
NoUpdateHash(&'a Path),
1817
ChecksumValid(&'a str),
1918
FileAlreadyDownloaded,
2019
CachedFileChecksumFailed,
21-
ExtensionNotInstalled(&'a str),
2220
MissingInstalledComponent(&'a str),
2321
/// The URL of the download is passed as the last argument, to allow us to track concurrent downloads.
2422
DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str),
@@ -30,11 +28,9 @@ pub enum Notification<'a> {
3028
DownloadingLegacyManifest,
3129
SkippingNightlyMissingComponent(&'a ToolchainDesc, &'a Manifest, &'a [Component]),
3230
ForcingUnavailableComponent(&'a str),
33-
ComponentUnavailable(&'a str, Option<&'a TargetTriple>),
3431
StrayHash(&'a Path),
35-
SignatureInvalid(&'a str),
3632
RetryingDownload(&'a str),
37-
DownloadingFile(&'a Url, &'a Path),
33+
DownloadingFile(&'a Url),
3834
/// Received the Content-Length of the to-be downloaded data with
3935
/// the respective URL of the download (for tracking concurrent downloads).
4036
DownloadContentLengthReceived(u64, Option<&'a str>),
@@ -50,6 +46,7 @@ pub enum Notification<'a> {
5046
/// utils::notifications by the time tar unpacking is called.
5147
SetDefaultBufferSize(usize),
5248
Error(String),
49+
#[cfg(feature = "curl-backend")]
5350
UsingCurl,
5451
UsingReqwest,
5552
SetAutoInstall(&'a str),
@@ -85,8 +82,7 @@ impl Notification<'_> {
8582
| NoUpdateHash(_)
8683
| FileAlreadyDownloaded
8784
| DownloadingLegacyManifest => NotificationLevel::Debug,
88-
Extracting(_, _)
89-
| DownloadingComponent(_, _, _, _)
85+
DownloadingComponent(_, _, _, _)
9086
| InstallingComponent(_, _, _)
9187
| RemovingComponent(_, _, _)
9288
| RemovingOldComponent(_, _, _)
@@ -96,22 +92,20 @@ impl Notification<'_> {
9692
| RetryingDownload(_)
9793
| DownloadedManifest(_, _) => NotificationLevel::Info,
9894
CantReadUpdateHash(_)
99-
| ExtensionNotInstalled(_)
10095
| MissingInstalledComponent(_)
10196
| CachedFileChecksumFailed
102-
| ComponentUnavailable(_, _)
10397
| ForcingUnavailableComponent(_)
10498
| StrayHash(_) => NotificationLevel::Warn,
105-
SignatureInvalid(_) => NotificationLevel::Warn,
10699
SetDefaultBufferSize(_) => NotificationLevel::Trace,
107-
DownloadingFile(_, _)
100+
DownloadingFile(_)
108101
| DownloadContentLengthReceived(_, _)
109102
| DownloadDataReceived(_, _)
110103
| DownloadFinished(_)
111104
| DownloadFailed(_)
112105
| ResumingPartialDownload
113-
| UsingCurl
114106
| UsingReqwest => NotificationLevel::Debug,
107+
#[cfg(feature = "curl-backend")]
108+
UsingCurl => NotificationLevel::Debug,
115109
Error(_) => NotificationLevel::Error,
116110
ToolchainDirectory(_)
117111
| LookingForToolchain(_)
@@ -139,18 +133,16 @@ impl Display for Notification<'_> {
139133
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::result::Result<(), fmt::Error> {
140134
use self::Notification::*;
141135
match self {
142-
Extracting(_, _) => write!(f, "extracting..."),
143136
ComponentAlreadyInstalled(c) => write!(f, "component {c} is up to date"),
144137
CantReadUpdateHash(path) => write!(
145138
f,
146139
"can't read update hash file: '{}', can't skip update...",
147140
path.display()
148141
),
149142
NoUpdateHash(path) => write!(f, "no update hash at: '{}'", path.display()),
150-
ChecksumValid(_) => write!(f, "checksum passed"),
143+
ChecksumValid(url) => write!(f, "checksum passed for {url}"),
151144
FileAlreadyDownloaded => write!(f, "reusing previously downloaded file"),
152145
CachedFileChecksumFailed => write!(f, "bad checksum for cached download"),
153-
ExtensionNotInstalled(c) => write!(f, "extension '{c}' was not installed"),
154146
MissingInstalledComponent(c) => {
155147
write!(f, "during uninstall component {c} was not found")
156148
}
@@ -195,13 +187,6 @@ impl Display for Notification<'_> {
195187
write!(f, "latest update on {date}, no rust version")
196188
}
197189
DownloadingLegacyManifest => write!(f, "manifest not found. trying legacy manifest"),
198-
ComponentUnavailable(pkg, toolchain) => {
199-
if let Some(tc) = toolchain {
200-
write!(f, "component '{pkg}' is not available on target '{tc}'")
201-
} else {
202-
write!(f, "component '{pkg}' is not available")
203-
}
204-
}
205190
StrayHash(path) => write!(
206191
f,
207192
"removing stray hash found at '{}' in order to continue",
@@ -226,20 +211,20 @@ impl Display for Notification<'_> {
226211
ForcingUnavailableComponent(component) => {
227212
write!(f, "Force-skipping unavailable component '{component}'")
228213
}
229-
SignatureInvalid(url) => write!(f, "Signature verification failed for '{url}'"),
230214
RetryingDownload(url) => write!(f, "retrying download for '{url}'"),
231215
Error(e) => write!(f, "error: '{e}'"),
232216
SetDefaultBufferSize(size) => write!(
233217
f,
234218
"using up to {} of RAM to unpack components",
235219
units::Size::new(*size)
236220
),
237-
DownloadingFile(url, _) => write!(f, "downloading file from: '{url}'"),
221+
DownloadingFile(url) => write!(f, "downloading file from: '{url}'"),
238222
DownloadContentLengthReceived(len, _) => write!(f, "download size is: '{len}'"),
239223
DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()),
240224
DownloadFinished(_) => write!(f, "download finished"),
241225
DownloadFailed(_) => write!(f, "download failed"),
242226
ResumingPartialDownload => write!(f, "resuming partial download"),
227+
#[cfg(feature = "curl-backend")]
243228
UsingCurl => write!(f, "downloading with curl"),
244229
UsingReqwest => write!(f, "downloading with reqwest"),
245230
SetAutoInstall(auto) => write!(f, "auto install set to '{auto}'"),

0 commit comments

Comments
 (0)