Skip to content

Commit

Permalink
Merge pull request #488 from bittorrent/fix/cidstore
Browse files Browse the repository at this point in the history
fix: cid is empty str.
  • Loading branch information
mengcody authored Dec 31, 2024
2 parents 1125003 + f52bac8 commit 37cb9ef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/commands/cidstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ var addCidCmd = &cmds.Command{
}

for _, v := range cids {
if v == "" {
continue
}
err = batch.Put(req.Context, datastore.NewKey(NewGatewayFilterKey(v)), []byte(v))
if err != nil {
return cmds.EmitOnce(res, err.Error())
Expand Down Expand Up @@ -220,6 +223,9 @@ func NewGatewayFilterKey(key string) string {

func validateCIDs(cids []string) error {
for _, c := range cids {
if c == "" {
continue
}
_, err := cid.Decode(c)
if err != nil {
return fmt.Errorf("Invalid CID: %s", c)
Expand Down

0 comments on commit 37cb9ef

Please sign in to comment.