From 160b1aaa74f925a625b481f317908e179e5617a5 Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Sat, 15 Jun 2019 22:55:17 +0000 Subject: [PATCH] Implemented something resembling offline mode. This will address #26 once we can merge this into master, until a `cargo` with offline mode hits stable/crates.io this branch can be used instead. --- Cargo.toml | 2 +- src/bin/cargo_semver.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8acb7bb222146..dd9c3d487b980 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ name = "rust-semver-public" path = "src/bin/rust_semver_public.rs" [dependencies] -cargo = "0.36" +cargo = { git = "https://github.com/rust-lang/cargo", branch = "master" } crates-io = "0.24" curl = "0.4.21" env_logger = "0.6" diff --git a/src/bin/cargo_semver.rs b/src/bin/cargo_semver.rs index 2c7e1b5902dc9..c719bab03f05f 100644 --- a/src/bin/cargo_semver.rs +++ b/src/bin/cargo_semver.rs @@ -83,7 +83,7 @@ fn main() { &None, // color false, // frozen false, // locked - // matches.opt_present("offline"), + matches.opt_present("offline"), &None, // target_dir &[], // unstable_flags ); @@ -441,7 +441,10 @@ impl<'a> WorkInfo<'a> { debug!("source id loaded: {:?}", source_id); - source.update()?; + if !config.offline() { + let _lock = config.acquire_package_cache_lock()?; + source.update()?; + } Box::new(source) };