Skip to content

Commit 2502b13

Browse files
rbtcollinsdjc
authored andcommitted
Make DownloadCfg::download_and_check async
1 parent 7e45922 commit 2502b13

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/dist/dist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ pub(crate) fn dl_v2_manifest(
10741074
toolchain: &ToolchainDesc,
10751075
) -> Result<Option<(ManifestV2, String)>> {
10761076
let manifest_url = toolchain.manifest_v2_url(download.dist_root);
1077-
match download.download_and_check(&manifest_url, update_hash, ".toml") {
1077+
match utils::run_future(download.download_and_check(&manifest_url, update_hash, ".toml")) {
10781078
Ok(manifest_dl) => {
10791079
// Downloaded ok!
10801080
let (manifest_file, manifest_hash) = if let Some(m) = manifest_dl {
@@ -1111,7 +1111,7 @@ fn dl_v1_manifest(download: DownloadCfg<'_>, toolchain: &ToolchainDesc) -> Resul
11111111
}
11121112

11131113
let manifest_url = toolchain.manifest_v1_url(download.dist_root);
1114-
let manifest_dl = download.download_and_check(&manifest_url, None, "")?;
1114+
let manifest_dl = utils::run_future(download.download_and_check(&manifest_url, None, ""))?;
11151115
let (manifest_file, _) = manifest_dl.unwrap();
11161116
let manifest_str = utils::read_file("manifest", &manifest_file)?;
11171117
let urls = manifest_str

src/dist/download.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ impl<'a> DownloadCfg<'a> {
143143
/// and if they match, the download is skipped.
144144
/// Verifies the signature found at the same url with a `.asc` suffix, and prints a
145145
/// warning when the signature does not verify, or is not found.
146-
pub(crate) fn download_and_check(
146+
pub(crate) async fn download_and_check(
147147
&self,
148148
url_str: &str,
149149
update_hash: Option<&Path>,
150150
ext: &str,
151151
) -> Result<Option<(temp::File<'a>, String)>> {
152-
let hash = utils::run_future(self.download_hash(url_str))?;
152+
let hash = self.download_hash(url_str).await?;
153153
let partial_hash: String = hash.chars().take(UPDATE_HASH_LEN).collect();
154154

155155
if let Some(hash_file) = update_hash {
@@ -171,9 +171,10 @@ impl<'a> DownloadCfg<'a> {
171171
let file = self.tmp_cx.new_file_with_ext("", ext)?;
172172

173173
let mut hasher = Sha256::new();
174-
utils::run_future(utils::download_file(&url, &file, Some(&mut hasher), &|n| {
174+
utils::download_file(&url, &file, Some(&mut hasher), &|n| {
175175
(self.notify_handler)(n.into())
176-
}))?;
176+
})
177+
.await?;
177178
let actual_hash = format!("{:x}", hasher.finalize());
178179

179180
if hash != actual_hash {

src/dist/manifestation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl Manifestation {
432432
notify_handler,
433433
};
434434

435-
let dl = dlcfg.download_and_check(&url, update_hash, ".tar.gz")?;
435+
let dl = utils::run_future(dlcfg.download_and_check(&url, update_hash, ".tar.gz"))?;
436436
if dl.is_none() {
437437
return Ok(None);
438438
};

0 commit comments

Comments
 (0)