Skip to content

Commit

Permalink
fixed usage of dag-pb codec
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
d70-t committed Oct 7, 2021
1 parent 7f53a46 commit 7b592e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ipfsspec/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ def req(endpoint):
else:
dag = req("dag/get")
data = UnixFSData()
data.ParseFromString(base64.b64decode(dag["data"]))
if "data" in dag:
data.ParseFromString(base64.b64decode(dag["data"]))
else:
rawdata = dag["Data"]["/"]["bytes"]
data.ParseFromString(base64.b64decode(rawdata + "=" * (-len(rawdata) % 4)))

size = data.filesize
if data.Type == data.File:
Expand Down

0 comments on commit 7b592e8

Please sign in to comment.