fix: refs must use new ipfspath.follow_dagpb_data
@@ -51,12 +51,18 @@ async fn refs_inner<T: IpfsTypes>(
formatter
);
- let paths = opts
+ let mut paths = opts
.arg
.iter()
.map(|s| IpfsPath::try_from(s.as_str()).map_err(StringError::from))
.collect::<Result<Vec<_>, _>>()?;
+ for path in paths.iter_mut() {
+ // this is needed because the paths should not error on matching on the final Data segment,
+ // it just becomes projected as `Loaded::Raw(_)`, however such items can have no links.
+ path.set_follow_dagpb_data(true);
+ }
+
let st = refs_paths(ipfs, paths, max_depth, opts.unique)
.await
.map_err(|e| {
@@ -367,10 +373,13 @@ fn handle_dagpb_not_found(
needle: String,
path: &IpfsPath,
) -> Result<(Cid, Loaded, Vec<String>), WalkError> {
+
+ use ipfs::unixfs::ll::dagpb::node_data;
+
if needle == "Data" && path.len() == 0 && path.follow_dagpb_data() {
- // /dag/resolve needs to "resolve through" a dag-pb node down to the "just
- // data" even though we do not need to extract it ... however this might be
- // good to just filter with refs, as no refs of such path exist
+ // /dag/resolve needs to "resolve through" a dag-pb node down to the "just data" even
+ // though we do not need to extract it ... however this might be good to just filter with
+ // refs, as no refs of such path can exist as the links are in the outer structure.
//
// testing with go-ipfs 0.5 reveals that dag resolve only follows links
// which are actually present in the dag-pb, not numeric links like Links/5
@@ -379,7 +388,7 @@ fn handle_dagpb_not_found(
// comment on this special casing: there cannot be any other such
// special case as the Links do not work like Data so while this is not
// pretty, it's not terrible.
- let data = ipfs::unixfs::ll::dagpb::node_data(&data)
+ let data = node_data(&data)
.expect("already parsed once, second time cannot fail")
.unwrap_or_default();
Ok((at, Loaded::Ipld(Ipld::Bytes(data.to_vec())), vec![needle]))
