Skip to content

Commit 7818bae

Browse files
committed
notifications: log directly for valid checksums
1 parent dc4b901 commit 7818bae

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/dist/download.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::path::{Path, PathBuf};
44

55
use anyhow::{Context, Result, anyhow};
66
use sha2::{Digest, Sha256};
7+
use tracing::debug;
78
use url::Url;
89

910
use crate::dist::temp;
@@ -50,7 +51,7 @@ impl<'a> DownloadCfg<'a> {
5051
let cached_result = file_hash(&target_file, self.notify_handler)?;
5152
if hash == cached_result {
5253
(self.notify_handler)(Notification::FileAlreadyDownloaded);
53-
(self.notify_handler)(Notification::ChecksumValid(url.as_ref()));
54+
debug!(url = url.as_ref(), "checksum passed");
5455
return Ok(File { path: target_file });
5556
} else {
5657
(self.notify_handler)(Notification::CachedFileChecksumFailed);
@@ -105,8 +106,7 @@ impl<'a> DownloadCfg<'a> {
105106
.into())
106107
}
107108
} else {
108-
(self.notify_handler)(Notification::ChecksumValid(url.as_ref()));
109-
109+
debug!(url = url.as_ref(), "checksum passed");
110110
utils::rename("downloaded", &partial_file_path, &target_file, self.process)?;
111111
Ok(File { path: target_file })
112112
}
@@ -190,7 +190,7 @@ impl<'a> DownloadCfg<'a> {
190190
}
191191
.into());
192192
} else {
193-
(self.notify_handler)(Notification::ChecksumValid(url_str));
193+
debug!(url = url_str, "checksum passed");
194194
}
195195

196196
Ok(Some((file, partial_hash)))

src/notifications.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub(crate) enum Notification<'a> {
1414
ComponentAlreadyInstalled(&'a str),
1515
CantReadUpdateHash(&'a Path),
1616
NoUpdateHash(&'a Path),
17-
ChecksumValid(&'a str),
1817
FileAlreadyDownloaded,
1918
CachedFileChecksumFailed,
2019
MissingInstalledComponent(&'a str),
@@ -75,10 +74,9 @@ impl Notification<'_> {
7574
pub(crate) fn level(&self) -> NotificationLevel {
7675
use self::Notification::*;
7776
match self {
78-
ChecksumValid(_)
79-
| NoUpdateHash(_)
80-
| FileAlreadyDownloaded
81-
| DownloadingLegacyManifest => NotificationLevel::Debug,
77+
NoUpdateHash(_) | FileAlreadyDownloaded | DownloadingLegacyManifest => {
78+
NotificationLevel::Debug
79+
}
8280
DownloadingComponent(_, _, _, _)
8381
| InstallingComponent(_, _, _)
8482
| RemovingComponent(_, _, _)
@@ -134,7 +132,6 @@ impl Display for Notification<'_> {
134132
path.display()
135133
),
136134
NoUpdateHash(path) => write!(f, "no update hash at: '{}'", path.display()),
137-
ChecksumValid(url) => write!(f, "checksum passed for {url}"),
138135
FileAlreadyDownloaded => write!(f, "reusing previously downloaded file"),
139136
CachedFileChecksumFailed => write!(f, "bad checksum for cached download"),
140137
MissingInstalledComponent(c) => {

0 commit comments

Comments
 (0)