File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
src/main/java/io/ipfs/api Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,13 @@ public static MerkleNode fromJSON(Object rawjson) {
5757 if (rawjson instanceof String )
5858 return new MerkleNode ((String )rawjson );
5959 Map json = (Map )rawjson ;
60+ if ("error" .equals (json .get ("Type" )))
61+ throw new IllegalStateException ("Remote IPFS error: " + json .get ("Message" ));
6062 String hash = (String )json .get ("Hash" );
6163 if (hash == null )
6264 hash = (String )json .get ("Key" );
63- if (hash == null )
64- hash = (String )(((Map )json .get ("Cid" )).get ("/" ));
65+ if (hash == null && json . containsKey ( "Cid" ) )
66+ hash = (String ) (((Map ) json .get ("Cid" )).get ("/" ));
6567 Optional <String > name = json .containsKey ("Name" ) ?
6668 Optional .of ((String ) json .get ("Name" )) :
6769 Optional .empty ();
@@ -72,8 +74,6 @@ public static MerkleNode fromJSON(Object rawjson) {
7274 Optional <String > largeSize = rawSize instanceof String ?
7375 Optional .of ((String ) json .get ("Size" )) :
7476 Optional .empty ();
75- if ("error" .equals (json .get ("Type" )))
76- throw new IllegalStateException ("Remote IPFS error: " + json .get ("Message" ));
7777 Optional <Integer > type = json .containsKey ("Type" ) ?
7878 Optional .of ((Integer ) json .get ("Type" )) :
7979 Optional .empty ();
You can’t perform that action at this time.
0 commit comments