Skip to content

Commit 7b39856

Browse files
committed
Give pin update a sensible return value
update multi-addr
1 parent 788ba9c commit 7b39856

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/multiaddr.jar

3.55 KB
Binary file not shown.

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@ public List<Multihash> rm(Multihash hash, boolean recursive) throws IOException
177177
return ((List<Object>) json.get("Pins")).stream().map(x -> Cid.decode((String) x)).collect(Collectors.toList());
178178
}
179179

180-
public Object update(Multihash existing, Multihash modified, boolean unpin) throws IOException {
181-
Object obj = retrieveAndParse("pin/update?stream-channels=true&arg=" + existing + "&arg=" + modified + "&unpin=" + unpin);
182-
return obj;
180+
public List<MultiAddress> update(Multihash existing, Multihash modified, boolean unpin) throws IOException {
181+
return ((List<Object>)((Map)retrieveAndParse("pin/update?stream-channels=true&arg=" + existing + "&arg=" + modified + "&unpin=" + unpin)).get("Pins"))
182+
.stream()
183+
.map(x -> new MultiAddress((String) x))
184+
.collect(Collectors.toList());
183185
}
184186
}
185187

src/test/java/io/ipfs/api/APITest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public void pinUpdate() {
215215

216216
CborObject.CborList root2 = new CborObject.CborList(Arrays.asList(new CborObject.CborMerkleLink(hashChild1), new CborObject.CborLong(42)));
217217
MerkleNode root2Res = ipfs.block.put(Collections.singletonList(root2.toByteArray()), Optional.of("cbor")).get(0);
218-
ipfs.pin.update(root1Res.hash, root2Res.hash, true);
218+
List<MultiAddress> update = ipfs.pin.update(root1Res.hash, root2Res.hash, true);
219219

220220
Map<Multihash, Object> ls = ipfs.pin.ls(IPFS.PinType.all);
221221
boolean childPresent = ls.containsKey(hashChild1);

0 commit comments

Comments
 (0)