77
88public class IPFS {
99
10- public static final String MIN_VERSION = "0.4.2 " ;
10+ public static final String MIN_VERSION = "0.4.4 " ;
1111 public enum PinType {all , direct , indirect , recursive }
1212 public List <String > ObjectTemplates = Arrays .asList ("unixfs-dir" );
1313 public List <String > ObjectPatchTypes = Arrays .asList ("add-link" , "rm-link" , "set-data" , "append-data" );
@@ -49,9 +49,11 @@ public IPFS(String host, int port, String version) {
4949 // Check IPFS is sufficiently recent
5050 try {
5151 String ipfsVersion = version ();
52- int [] parts = Stream .of (ipfsVersion .split ("\\ ." )).mapToInt (Integer ::parseInt ).toArray ();
53- int [] minParts = Stream .of (MIN_VERSION .split ("\\ ." )).mapToInt (Integer ::parseInt ).toArray ();
54- if (parts [0 ] < minParts [0 ] || parts [1 ] < minParts [1 ] || parts [2 ] < minParts [2 ])
52+ String [] parts = ipfsVersion .split ("\\ ." );
53+ String [] minParts = MIN_VERSION .split ("\\ ." );
54+ if (parts [0 ].compareTo (minParts [0 ]) < 0
55+ || parts [1 ].compareTo (minParts [1 ]) < 0
56+ || parts [2 ].compareTo (minParts [2 ]) < 0 )
5557 throw new IllegalStateException ("You need to use a more recent version of IPFS! >= " + MIN_VERSION );
5658 } catch (IOException e ) {
5759 throw new RuntimeException (e );
@@ -68,7 +70,6 @@ public List<MerkleNode> add(List<NamedStreamable> files) throws IOException {
6870 m .addFilePart ("file" , f );
6971 String res = m .finish ();
7072 return JSONParser .parseStream (res ).stream ()
71- .skip (1 )
7273 .map (x -> MerkleNode .fromJSON ((Map <String , Object >) x ))
7374 .collect (Collectors .toList ());
7475 }
0 commit comments