Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Commit

Permalink
fix: remove unwrap from refs-local
Browse files Browse the repository at this point in the history
kept the return value as a stream. it'll at least save us the trouble of
concatenating all of the values into a big vector.
  • Loading branch information
Joonas Koivunen committed Apr 15, 2020
1 parent 359088b commit e67f819
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions http/src/v0/refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ pub fn local<T: IpfsTypes>(
}

async fn inner_local<T: IpfsTypes>(ipfs: Ipfs<T>) -> Result<impl Reply, Rejection> {
let refs: Vec<Result<String, Error>> = ipfs
let refs = ipfs
.refs_local()
.await
.map_err(StringError::from)?
Expand All @@ -367,14 +367,15 @@ async fn inner_local<T: IpfsTypes>(ipfs: Ipfs<T>) -> Result<impl Reply, Rejectio
})
.map(|response| {
serde_json::to_string(&response)
.map(|mut s| {
s.push('\n');
s
})
.map_err(|e| {
eprintln!("error from serde_json: {}", e);
HandledErr
})
.unwrap()
})
.map(|ref_json| Ok(format!("{}{}", ref_json, "\n")))
.collect();
});

let stream = stream::iter(refs);
Ok(warp::reply::Response::new(Body::wrap_stream(stream)))
Expand Down

0 comments on commit e67f819

Please sign in to comment.