Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
fix: Avoid locking if selecting ws member
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Mar 22, 2024
1 parent c251f0a commit bcc5b79
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
33 changes: 21 additions & 12 deletions src/ops/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,27 @@ fn find_pkgid_in_ws(
ws: Option<&cargo::core::Workspace<'_>>,
spec: &PackageIdSpec,
) -> (Option<PackageId>, bool) {
let (package_id, is_member) = ws
.as_ref()
.and_then(|ws| ops::resolve_ws(ws).map(|(_, resolve)| (ws, resolve)).ok())
.and_then(|(ws, resolve)| {
let package_id = resolve
.iter()
.filter(|&p| spec.matches(p))
.max_by_key(|&p| p.version());
package_id.map(|pid| (Some(pid), ws.members().any(|p| p.package_id() == pid)))
})
.unwrap_or((None, false));
(package_id, is_member)
let Some(ws) = ws else {
return (None, false);
};

if let Some(member) = ws.members().find(|p| spec.matches(p.package_id())) {
return (Some(member.package_id()), true);
}

let Ok((_, resolve)) = ops::resolve_ws(ws) else {
return (None, false);
};

if let Some(package_id) = resolve
.iter()
.filter(|&p| spec.matches(p))
.max_by_key(|&p| p.version())
{
return (Some(package_id), false);
}

(None, false)
}

fn find_pkgid_in_summaries(
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
Updating git repository `[ROOTURL]/baz`
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
Updating `dummy-registry` index

0 comments on commit bcc5b79

Please sign in to comment.