Skip to content

Commit d00163e

Browse files
committed
notifications: privatize Notification type
1 parent 6a02529 commit d00163e

File tree

4 files changed

+9
-27
lines changed

4 files changed

+9
-27
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: 6 additions & 24 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>),
@@ -85,8 +81,7 @@ impl Notification<'_> {
8581
| NoUpdateHash(_)
8682
| FileAlreadyDownloaded
8783
| DownloadingLegacyManifest => NotificationLevel::Debug,
88-
Extracting(_, _)
89-
| DownloadingComponent(_, _, _, _)
84+
DownloadingComponent(_, _, _, _)
9085
| InstallingComponent(_, _, _)
9186
| RemovingComponent(_, _, _)
9287
| RemovingOldComponent(_, _, _)
@@ -96,15 +91,12 @@ impl Notification<'_> {
9691
| RetryingDownload(_)
9792
| DownloadedManifest(_, _) => NotificationLevel::Info,
9893
CantReadUpdateHash(_)
99-
| ExtensionNotInstalled(_)
10094
| MissingInstalledComponent(_)
10195
| CachedFileChecksumFailed
102-
| ComponentUnavailable(_, _)
10396
| ForcingUnavailableComponent(_)
10497
| StrayHash(_) => NotificationLevel::Warn,
105-
SignatureInvalid(_) => NotificationLevel::Warn,
10698
SetDefaultBufferSize(_) => NotificationLevel::Trace,
107-
DownloadingFile(_, _)
99+
DownloadingFile(_)
108100
| DownloadContentLengthReceived(_, _)
109101
| DownloadDataReceived(_, _)
110102
| DownloadFinished(_)
@@ -139,18 +131,16 @@ impl Display for Notification<'_> {
139131
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::result::Result<(), fmt::Error> {
140132
use self::Notification::*;
141133
match self {
142-
Extracting(_, _) => write!(f, "extracting..."),
143134
ComponentAlreadyInstalled(c) => write!(f, "component {c} is up to date"),
144135
CantReadUpdateHash(path) => write!(
145136
f,
146137
"can't read update hash file: '{}', can't skip update...",
147138
path.display()
148139
),
149140
NoUpdateHash(path) => write!(f, "no update hash at: '{}'", path.display()),
150-
ChecksumValid(_) => write!(f, "checksum passed"),
141+
ChecksumValid(url) => write!(f, "checksum passed for {url}"),
151142
FileAlreadyDownloaded => write!(f, "reusing previously downloaded file"),
152143
CachedFileChecksumFailed => write!(f, "bad checksum for cached download"),
153-
ExtensionNotInstalled(c) => write!(f, "extension '{c}' was not installed"),
154144
MissingInstalledComponent(c) => {
155145
write!(f, "during uninstall component {c} was not found")
156146
}
@@ -195,13 +185,6 @@ impl Display for Notification<'_> {
195185
write!(f, "latest update on {date}, no rust version")
196186
}
197187
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-
}
205188
StrayHash(path) => write!(
206189
f,
207190
"removing stray hash found at '{}' in order to continue",
@@ -226,15 +209,14 @@ impl Display for Notification<'_> {
226209
ForcingUnavailableComponent(component) => {
227210
write!(f, "Force-skipping unavailable component '{component}'")
228211
}
229-
SignatureInvalid(url) => write!(f, "Signature verification failed for '{url}'"),
230212
RetryingDownload(url) => write!(f, "retrying download for '{url}'"),
231213
Error(e) => write!(f, "error: '{e}'"),
232214
SetDefaultBufferSize(size) => write!(
233215
f,
234216
"using up to {} of RAM to unpack components",
235217
units::Size::new(*size)
236218
),
237-
DownloadingFile(url, _) => write!(f, "downloading file from: '{url}'"),
219+
DownloadingFile(url) => write!(f, "downloading file from: '{url}'"),
238220
DownloadContentLengthReceived(len, _) => write!(f, "download size is: '{len}'"),
239221
DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()),
240222
DownloadFinished(_) => write!(f, "download finished"),

0 commit comments

Comments
 (0)