Skip to content

Commit

Permalink
fix(resolver): node paths should use their fs name
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Sep 30, 2023
1 parent 2462655 commit 544639b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions crates/node-maintainer/src/graph.rs
Expand Up @@ -35,6 +35,8 @@ pub(crate) struct DemotionTarget {
pub struct Node {
/// Index of this Node inside its [`Graph`].
pub(crate) idx: NodeIndex,
/// Name this node is written to the filesystem as.
pub(crate) name: UniCase<String>,
/// Resolved [`Package`] for this Node.
pub(crate) package: Package,
/// Quick index back to this Node's [`Graph`]'s root Node.
Expand All @@ -53,6 +55,7 @@ pub struct Node {

impl Node {
pub(crate) fn new(
name: UniCase<String>,
package: Package,
manifest: CorgiManifest,
is_root: bool,
Expand Down Expand Up @@ -89,6 +92,7 @@ impl Node {
}
Ok(Self {
package,
name,
idx: NodeIndex::new(0),
root: NodeIndex::new(0),
parent: None,
Expand Down Expand Up @@ -291,15 +295,13 @@ impl Graph {
let node = &self.inner[node_idx];
let mut path = VecDeque::new();
if node_idx != self.root {
path.push_front(UniCase::new(node.package.name().to_owned()));
path.push_front(node.name.clone());
let mut parent = node.parent;
while let Some(parent_idx) = parent {
if parent_idx == self.root {
break;
}
path.push_front(UniCase::new(
self.inner[parent_idx].package.name().to_owned(),
));
path.push_front(self.inner[parent_idx].name.clone());
parent = self.inner[parent_idx].parent;
}
};
Expand Down
5 changes: 3 additions & 2 deletions crates/node-maintainer/src/maintainer.rs
Expand Up @@ -6,6 +6,7 @@ use async_std::fs;
use nassun::client::{Nassun, NassunOpts};
use nassun::package::Package;
use oro_common::CorgiManifest;
use unicase::UniCase;
use url::Url;

#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -350,7 +351,7 @@ impl NodeMaintainerOptions {
let node = resolver
.graph
.inner
.add_node(Node::new(root_pkg, root, true)?);
.add_node(Node::new(UniCase::new("".to_string()), root_pkg, root, true)?);
resolver.graph[node].root = node;
let (graph, _actual_tree) = resolver.run_resolver(lockfile).await?;
#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -406,7 +407,7 @@ impl NodeMaintainerOptions {
let node = resolver
.graph
.inner
.add_node(Node::new(root_pkg, corgi, true)?);
.add_node(Node::new(UniCase::new("".to_string()), root_pkg, corgi, true)?);
resolver.graph[node].root = node;
let (graph, _actual_tree) = resolver.run_resolver(lockfile).await?;
#[cfg(not(target_arch = "wasm32"))]
Expand Down
2 changes: 1 addition & 1 deletion crates/node-maintainer/src/resolver.rs
Expand Up @@ -351,7 +351,7 @@ impl<'a> Resolver<'a> {
let requested = &dep.spec;
let dep_type = dep.dep_type;
let dependent_idx = dep.node_idx;
let child_node = Node::new(package, corgi, false)?;
let child_node = Node::new(child_name.clone(), package, corgi, false)?;
let child_idx = graph.inner.add_node(child_node);
graph[child_idx].root = graph.root;
// We needed to generate the node index before setting it in the node,
Expand Down

0 comments on commit 544639b

Please sign in to comment.