Skip to content

Commit ebc4bee

Browse files
committed
rust: produce install only archives in parallel
This speeds things up a bit. I could use async for this. But rayon is simpler.
1 parent deaadb7 commit ebc4bee

File tree

3 files changed

+125
-18
lines changed

3 files changed

+125
-18
lines changed

Cargo.lock

Lines changed: 101 additions & 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
@@ -14,6 +14,7 @@ futures = "0"
1414
goblin = "0"
1515
octocrab = { version = "0", features = ["rustls"] }
1616
once_cell = "1"
17+
rayon = "1"
1718
reqwest = {version = "0", features = ["rustls"] }
1819
scroll = "0"
1920
semver = "1"

src/github.rs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use {
88
clap::ArgMatches,
99
futures::StreamExt,
1010
octocrab::{models::workflows::WorkflowListArtifact, Octocrab, OctocrabBuilder},
11+
rayon::prelude::*,
1112
std::{collections::BTreeSet, io::Read, path::PathBuf},
1213
zip::ZipArchive,
1314
};
@@ -152,24 +153,28 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
152153
}
153154
}
154155

155-
for path in install_paths {
156-
println!(
157-
"producing install_only archive from {}",
158-
path.file_name()
159-
.expect("should have file name")
160-
.to_string_lossy()
161-
);
162-
163-
let dest_path = produce_install_only(&path)?;
164-
165-
println!(
166-
"releasing {}",
167-
dest_path
168-
.file_name()
169-
.expect("should have file name")
170-
.to_string_lossy()
171-
);
172-
}
156+
install_paths
157+
.par_iter()
158+
.try_for_each(|path| -> Result<()> {
159+
println!(
160+
"producing install_only archive from {}",
161+
path.file_name()
162+
.expect("should have file name")
163+
.to_string_lossy()
164+
);
165+
166+
let dest_path = produce_install_only(&path)?;
167+
168+
println!(
169+
"releasing {}",
170+
dest_path
171+
.file_name()
172+
.expect("should have file name")
173+
.to_string_lossy()
174+
);
175+
176+
Ok(())
177+
})?;
173178

174179
Ok(())
175180
}

0 commit comments

Comments
 (0)