Skip to content

Commit 551616d

Browse files
committed
fixup! Do not load
1 parent ab9b16c commit 551616d

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ tar = "0.4.40"
3737
tempfile = "3.10.0"
3838
text-stub-library = "0.9.0"
3939
tokio = "1.43.1"
40+
tokio-util = "0.7.13"
4041
url = "2.5.0"
4142
version-compare = "0.1.1"
4243
zip = "0.6.6"

src/github.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use {
2929
str::FromStr,
3030
time::{Duration, SystemTime},
3131
},
32-
tokio::io::AsyncReadExt,
3332
url::Url,
3433
zip::ZipArchive,
3534
};
@@ -540,19 +539,15 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
540539
// reqwest wants to take ownership of the body, so it's hard for us to do anything
541540
// clever with reading the file once and calculating the sha256sum while we read.
542541
// So we open and read the file again.
543-
let mut file = tokio::fs::File::open(local_filename).await?;
544-
let mut hasher = Sha256::new();
545-
let mut buf = vec![0; 1048576];
546-
loop {
547-
let len = file.read(&mut buf).await?;
548-
if len == 0 {
549-
break;
550-
};
551-
hasher.update(&buf);
552-
}
553-
drop(file);
554-
555-
let digest = hex::encode(hasher.finalize());
542+
let digest = {
543+
let file = tokio::fs::File::open(local_filename).await?;
544+
let mut stream = tokio_util::io::ReaderStream::with_capacity(file, 1048576);
545+
let mut hasher = Sha256::new();
546+
while let Some(chunk) = stream.next().await {
547+
hasher.update(&chunk?);
548+
}
549+
hex::encode(hasher.finalize())
550+
};
556551
digests.insert(dest.clone(), digest.clone());
557552
fs.push(upload_release_artifact(
558553
&raw_client,

0 commit comments

Comments
 (0)