mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 05:28:42 +00:00
Fix jobserver_client
: Create it as early as possible
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
2bf7640729
commit
67ca36a0b5
1 changed files with 8 additions and 5 deletions
13
src/main.rs
13
src/main.rs
|
@ -171,10 +171,16 @@ impl Termination for MainExit {
|
|||
}
|
||||
|
||||
fn main() -> MainExit {
|
||||
// Create jobserver client
|
||||
let jobserver_client = match create_jobserver_client() {
|
||||
Ok(jobserver_client) => jobserver_client,
|
||||
Err(binstall_err) => return MainExit::Error(binstall_err),
|
||||
};
|
||||
|
||||
let start = Instant::now();
|
||||
|
||||
let rt = Runtime::new().unwrap();
|
||||
let handle = rt.spawn(entry());
|
||||
let handle = rt.spawn(entry(jobserver_client));
|
||||
let result = rt.block_on(handle);
|
||||
drop(rt);
|
||||
|
||||
|
@ -190,7 +196,7 @@ fn main() -> MainExit {
|
|||
})
|
||||
}
|
||||
|
||||
async fn entry() -> Result<()> {
|
||||
async fn entry(jobserver_client: jobserver::Client) -> Result<()> {
|
||||
// Filter extraneous arg when invoked by cargo
|
||||
// `cargo run -- --help` gives ["target/debug/cargo-binstall", "--help"]
|
||||
// `cargo binstall --help` gives ["/home/ryan/.cargo/bin/cargo-binstall", "binstall", "--help"]
|
||||
|
@ -209,9 +215,6 @@ async fn entry() -> Result<()> {
|
|||
let crate_names = take(&mut opts.crate_names);
|
||||
let opts = Arc::new(opts);
|
||||
|
||||
// Create jobserver client
|
||||
let jobserver_client = create_jobserver_client()?;
|
||||
|
||||
// Initialize reqwest client
|
||||
let client = create_reqwest_client(opts.secure, opts.min_tls_version.map(|v| v.into()))?;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue