mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Factor out poll_one_package
This commit is contained in:
parent
3121a7175d
commit
431d84a6bf
@ -21,6 +21,7 @@ use crate::core::manifest::ManifestMetadata;
|
|||||||
use crate::core::resolver::CliFeatures;
|
use crate::core::resolver::CliFeatures;
|
||||||
use crate::core::Dependency;
|
use crate::core::Dependency;
|
||||||
use crate::core::Package;
|
use crate::core::Package;
|
||||||
|
use crate::core::PackageId;
|
||||||
use crate::core::PackageIdSpecQuery;
|
use crate::core::PackageIdSpecQuery;
|
||||||
use crate::core::SourceId;
|
use crate::core::SourceId;
|
||||||
use crate::core::Workspace;
|
use crate::core::Workspace;
|
||||||
@ -28,6 +29,7 @@ use crate::ops;
|
|||||||
use crate::ops::PackageOpts;
|
use crate::ops::PackageOpts;
|
||||||
use crate::ops::Packages;
|
use crate::ops::Packages;
|
||||||
use crate::sources::source::QueryKind;
|
use crate::sources::source::QueryKind;
|
||||||
|
use crate::sources::source::Source;
|
||||||
use crate::sources::SourceConfigMap;
|
use crate::sources::SourceConfigMap;
|
||||||
use crate::sources::CRATES_IO_REGISTRY;
|
use crate::sources::CRATES_IO_REGISTRY;
|
||||||
use crate::util::auth;
|
use crate::util::auth;
|
||||||
@ -189,14 +191,12 @@ fn wait_for_publish(
|
|||||||
pkg: &Package,
|
pkg: &Package,
|
||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
) -> CargoResult<()> {
|
) -> CargoResult<()> {
|
||||||
let version_req = format!("={}", pkg.version());
|
|
||||||
let mut source = SourceConfigMap::empty(gctx)?.load(registry_src, &HashSet::new())?;
|
let mut source = SourceConfigMap::empty(gctx)?.load(registry_src, &HashSet::new())?;
|
||||||
// Disable the source's built-in progress bars. Repeatedly showing a bunch
|
// Disable the source's built-in progress bars. Repeatedly showing a bunch
|
||||||
// of independent progress bars can be a little confusing. There is an
|
// of independent progress bars can be a little confusing. There is an
|
||||||
// overall progress bar managed here.
|
// overall progress bar managed here.
|
||||||
source.set_quiet(true);
|
source.set_quiet(true);
|
||||||
let source_description = source.source_id().to_string();
|
let source_description = source.source_id().to_string();
|
||||||
let query = Dependency::parse(pkg.name(), Some(&version_req), registry_src)?;
|
|
||||||
|
|
||||||
let now = std::time::Instant::now();
|
let now = std::time::Instant::now();
|
||||||
let sleep_time = Duration::from_secs(1);
|
let sleep_time = Duration::from_secs(1);
|
||||||
@ -223,16 +223,7 @@ fn wait_for_publish(
|
|||||||
// multiple times
|
// multiple times
|
||||||
gctx.updated_sources().remove(&source.replaced_source_id());
|
gctx.updated_sources().remove(&source.replaced_source_id());
|
||||||
source.invalidate_cache();
|
source.invalidate_cache();
|
||||||
let summaries = loop {
|
if poll_one_package(registry_src, &pkg.package_id(), &mut source)? {
|
||||||
// Exact to avoid returning all for path/git
|
|
||||||
match source.query_vec(&query, QueryKind::Exact) {
|
|
||||||
std::task::Poll::Ready(res) => {
|
|
||||||
break res?;
|
|
||||||
}
|
|
||||||
std::task::Poll::Pending => source.block_until_ready()?,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if !summaries.is_empty() {
|
|
||||||
break true;
|
break true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,6 +253,25 @@ fn wait_for_publish(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn poll_one_package(
|
||||||
|
registry_src: SourceId,
|
||||||
|
pkg_id: &PackageId,
|
||||||
|
source: &mut dyn Source,
|
||||||
|
) -> CargoResult<bool> {
|
||||||
|
let version_req = format!("={}", pkg_id.version());
|
||||||
|
let query = Dependency::parse(pkg_id.name(), Some(&version_req), registry_src)?;
|
||||||
|
let summaries = loop {
|
||||||
|
// Exact to avoid returning all for path/git
|
||||||
|
match source.query_vec(&query, QueryKind::Exact) {
|
||||||
|
std::task::Poll::Ready(res) => {
|
||||||
|
break res?;
|
||||||
|
}
|
||||||
|
std::task::Poll::Pending => source.block_until_ready()?,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Ok(!summaries.is_empty())
|
||||||
|
}
|
||||||
|
|
||||||
fn verify_dependencies(
|
fn verify_dependencies(
|
||||||
pkg: &Package,
|
pkg: &Package,
|
||||||
registry: &Registry,
|
registry: &Registry,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user