Skip to content

Commit

Permalink
Updated to IPFS 0.4.2 API
Browse files Browse the repository at this point in the history
  • Loading branch information
ianopolous committed Jun 13, 2016
1 parent 9d4244b commit b36d020
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/org/ipfs/api/IPFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public List<MerkleNode> add(List<NamedStreamable> files) throws IOException {
for (NamedStreamable f : files)
m.addFilePart("file", f);
String res = m.finish();
return JSONParser.parseStream(res).stream().map(x -> MerkleNode.fromJSON((Map<String, Object>) x)).collect(Collectors.toList());
return JSONParser.parseStream(res).stream()
.skip(1)
.map(x -> MerkleNode.fromJSON((Map<String, Object>) x))
.collect(Collectors.toList());
}

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

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/ipfs/api/JSONParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public static List<Object> parseStream(String json)
return null;
int[] pos = new int[1];
List<Object> res = new ArrayList<>();
json = json.trim();
while (pos[0] < json.length())
res.add(parse(json, pos));
return res;
Expand Down

0 comments on commit b36d020

Please sign in to comment.