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

Commit 5def58d

Browse files
author
Joonas Koivunen
committed
fix: remove unwrap from refs-local
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.
1 parent 8741db7 commit 5def58d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

http/src/v0/refs.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ pub fn local<T: IpfsTypes>(
355355
}
356356

357357
async fn inner_local<T: IpfsTypes>(ipfs: Ipfs<T>) -> Result<impl Reply, Rejection> {
358-
let refs: Vec<Result<String, Error>> = ipfs
358+
let refs = ipfs
359359
.refs_local()
360360
.await
361361
.map_err(StringError::from)?
@@ -367,14 +367,15 @@ async fn inner_local<T: IpfsTypes>(ipfs: Ipfs<T>) -> Result<impl Reply, Rejectio
367367
})
368368
.map(|response| {
369369
serde_json::to_string(&response)
370+
.map(|mut s| {
371+
s.push('\n');
372+
s
373+
})
370374
.map_err(|e| {
371375
eprintln!("error from serde_json: {}", e);
372376
HandledErr
373377
})
374-
.unwrap()
375-
})
376-
.map(|ref_json| Ok(format!("{}{}", ref_json, "\n")))
377-
.collect();
378+
});
378379

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

0 commit comments

Comments
 (0)