Skip to content

Commit b36d020

Browse files
committed
Updated to IPFS 0.4.2 API
1 parent 9d4244b commit b36d020

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/main/java/org/ipfs/api/IPFS.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ public List<MerkleNode> add(List<NamedStreamable> files) throws IOException {
5555
for (NamedStreamable f : files)
5656
m.addFilePart("file", f);
5757
String res = m.finish();
58-
return JSONParser.parseStream(res).stream().map(x -> MerkleNode.fromJSON((Map<String, Object>) x)).collect(Collectors.toList());
58+
return JSONParser.parseStream(res).stream()
59+
.skip(1)
60+
.map(x -> MerkleNode.fromJSON((Map<String, Object>) x))
61+
.collect(Collectors.toList());
5962
}
6063

6164
public List<MerkleNode> ls(Multihash hash) throws IOException {
@@ -101,7 +104,11 @@ public Map mount(java.io.File ipfsRoot, java.io.File ipnsRoot) throws IOExceptio
101104
// level 2 commands
102105
public class Refs {
103106
public List<Multihash> local() throws IOException {
104-
return Arrays.asList(new String(retrieve("refs/local")).split("\n")).stream().map(Multihash::fromBase58).collect(Collectors.toList());
107+
String jsonStream = new String(retrieve("refs/local"));
108+
return JSONParser.parseStream(jsonStream).stream()
109+
.map(m -> (String) (((Map) m).get("Ref")))
110+
.map(Multihash::fromBase58)
111+
.collect(Collectors.toList());
105112
}
106113
}
107114

src/main/java/org/ipfs/api/JSONParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ public static List<Object> parseStream(String json)
274274
return null;
275275
int[] pos = new int[1];
276276
List<Object> res = new ArrayList<>();
277+
json = json.trim();
277278
while (pos[0] < json.length())
278279
res.add(parse(json, pos));
279280
return res;

0 commit comments

Comments
 (0)