Skip to content

Commit 7b592e8

Browse files
committed
fixed usage of dag-pb codec
Since go-ipfs v0.10.0, data in dag-pb is encoded differently when retrieved as JSON. This change accepts both variants (old and new).
1 parent 7f53a46 commit 7b592e8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ipfsspec/core.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,11 @@ def req(endpoint):
231231
else:
232232
dag = req("dag/get")
233233
data = UnixFSData()
234-
data.ParseFromString(base64.b64decode(dag["data"]))
234+
if "data" in dag:
235+
data.ParseFromString(base64.b64decode(dag["data"]))
236+
else:
237+
rawdata = dag["Data"]["/"]["bytes"]
238+
data.ParseFromString(base64.b64decode(rawdata + "=" * (-len(rawdata) % 4)))
235239

236240
size = data.filesize
237241
if data.Type == data.File:

0 commit comments

Comments
 (0)