Skip to content

Commit 479654d

Browse files
committed
add items to repo api
1 parent 7ba2bc6 commit 479654d

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,24 @@ public String transcode(Optional<String> encoding, NamedStreamable file) {
316316
/* 'ipfs repo' is a plumbing command used to manipulate the repo.
317317
*/
318318
public class Repo {
319-
public Object gc() throws IOException {
320-
return retrieveAndParse("repo/gc");
319+
public Map gc() throws IOException {
320+
return retrieveMap("repo/gc");
321+
}
322+
public Multihash ls() throws IOException {
323+
Map res = retrieveMap("repo/ls");
324+
return Cid.decode((String)res.get("Ref"));
325+
}
326+
/*public String migrate(boolean allowDowngrade) throws IOException {
327+
return retrieveString("repo/migrate?allow-downgrade=" + allowDowngrade);
328+
}*/
329+
public Map stat(boolean sizeOnly, boolean humanReadable) throws IOException {
330+
return retrieveMap("repo/stat?size-only=" + sizeOnly + "&human=" + humanReadable);
331+
}
332+
public Map verify() throws IOException {
333+
return retrieveMap("repo/verify");
334+
}
335+
public Map version() throws IOException {
336+
return retrieveMap("repo/version");
321337
}
322338
}
323339

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,15 @@ public void fileContentsTest() throws IOException {
677677
}
678678
}
679679

680+
@Test
681+
public void repoTest() throws IOException {
682+
ipfs.repo.gc();
683+
Multihash res = ipfs.repo.ls();
684+
//String migration = ipfs.repo.migrate(false);
685+
Map stat = ipfs.repo.stat(false, true);
686+
Map verify = ipfs.repo.verify();
687+
Map version = ipfs.repo.version();
688+
}
680689
@Test
681690
@Ignore("name test may hang forever")
682691
public void nameTest() throws IOException {

0 commit comments

Comments
 (0)