Skip to content

Commit

Permalink
Store cid as byte value of its string representation
Browse files Browse the repository at this point in the history
So that we maintain valid UTF-8 encoding for the postgres datastore.
  • Loading branch information
masih committed Mar 4, 2022
1 parent ccc4bc6 commit 70461ee
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions controller/publisher/pando_publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,11 @@ func (p *PandoPublisher) getLatest(ctx context.Context) (cid.Cid, error) {
if err != nil {
return cid.Undef, err
}
_, latest, err := cid.CidFromBytes(d)
return latest, err
return cid.Decode(string(d))
}

func (p *PandoPublisher) setLatest(ctx context.Context, c cid.Cid) error {
return p.ds.Put(ctx, latestPublishedCid, c.Bytes())
return p.ds.Put(ctx, latestPublishedCid, []byte(c.String()))
}

func (p *PandoPublisher) storageReadOpener(lc linking.LinkContext, l ipld.Link) (io.Reader, error) {
Expand Down

0 comments on commit 70461ee

Please sign in to comment.