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) {
57
57
if (rawjson instanceof String )
58
58
return new MerkleNode ((String )rawjson );
59
59
Map json = (Map )rawjson ;
60
+ if ("error" .equals (json .get ("Type" )))
61
+ throw new IllegalStateException ("Remote IPFS error: " + json .get ("Message" ));
60
62
String hash = (String )json .get ("Hash" );
61
63
if (hash == null )
62
64
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 ("/" ));
65
67
Optional <String > name = json .containsKey ("Name" ) ?
66
68
Optional .of ((String ) json .get ("Name" )) :
67
69
Optional .empty ();
@@ -72,8 +74,6 @@ public static MerkleNode fromJSON(Object rawjson) {
72
74
Optional <String > largeSize = rawSize instanceof String ?
73
75
Optional .of ((String ) json .get ("Size" )) :
74
76
Optional .empty ();
75
- if ("error" .equals (json .get ("Type" )))
76
- throw new IllegalStateException ("Remote IPFS error: " + json .get ("Message" ));
77
77
Optional <Integer > type = json .containsKey ("Type" ) ?
78
78
Optional .of ((Integer ) json .get ("Type" )) :
79
79
Optional .empty ();
You can’t perform that action at this time.
0 commit comments