ipfsproxy: fix 'undefined cid' string appeareance in progress output

Fixes #1286. Some AddedOutput objects carry an undefined CID. This was getting
stringified as 'b', making the proxy responses include this rather than
skipping setting the field.
This commit is contained in:
Hector Sanjuan 2021-01-13 16:29:15 +01:00
parent c78f7839a2
commit a39ee13834

View File

@ -563,9 +563,13 @@ func (proxy *Server) addHandler(w http.ResponseWriter, r *http.Request) {
logger.Warnf("Proxy/add does not support all IPFS params. Current options: %+v", params)
outputTransform := func(in *api.AddedOutput) interface{} {
cidStr := ""
if in.Cid.Defined() {
cidStr = in.Cid.String()
}
r := &ipfsAddResp{
Name: in.Name,
Hash: in.Cid.String(),
Hash: cidStr,
Bytes: int64(in.Bytes),
}
if in.Size != 0 {