refactor: use ipfs.dag().resolve in http
perhaps the error message requirements have changed, since this worked right away? aah nope, they must concern other uses of walk_path. well, this passes the tests either way.
This commit is contained in:
parent
08782f9b58
commit
981a67d781
@ -121,38 +121,23 @@ async fn inner_resolve<T: IpfsTypes>(
|
||||
ipfs: Ipfs<T>,
|
||||
opts: ResolveOptions,
|
||||
) -> Result<impl Reply, Rejection> {
|
||||
use crate::v0::refs::{walk_path, IpfsPath, WalkOptions};
|
||||
use ipfs::IpfsPath;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
let path = IpfsPath::try_from(opts.arg.as_str()).map_err(StringError::from)?;
|
||||
|
||||
let walk_opts = WalkOptions {
|
||||
follow_dagpb_data: true,
|
||||
};
|
||||
|
||||
let (current, _, remaining) = walk_path(&ipfs, &walk_opts, path)
|
||||
let (resolved, remaining) = ipfs
|
||||
.dag()
|
||||
.resolve(path, /* FIXME: query */ true)
|
||||
.maybe_timeout(opts.timeout.map(StringSerialized::into_inner))
|
||||
.await
|
||||
.map_err(StringError::from)?
|
||||
.map_err(StringError::from)?;
|
||||
|
||||
let remaining = {
|
||||
let slashes = remaining.len();
|
||||
let mut buf =
|
||||
String::with_capacity(remaining.iter().map(|s| s.len()).sum::<usize>() + slashes);
|
||||
|
||||
for piece in remaining.into_iter().rev() {
|
||||
if !buf.is_empty() {
|
||||
buf.push('/');
|
||||
}
|
||||
buf.push_str(&piece);
|
||||
}
|
||||
|
||||
buf
|
||||
};
|
||||
let current = resolved.cid();
|
||||
|
||||
Ok(reply::json(&json!({
|
||||
"Cid": { "/": current.to_string() },
|
||||
"RemPath": remaining,
|
||||
"RemPath": StringSerialized(remaining),
|
||||
})))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user