ipfs / helia

An implementation of IPFS in JavaScript
https://helia.io
Other
916 stars 99 forks source link

Helia throws when adding a block if it is already pinned #642

Open justin0mcateer opened 1 week ago

justin0mcateer commented 1 week ago

When adding content to Helia and setting the 'pin' option to true, if a pin exists the add method will throw a generic error with the message 'Already Pinned'.

The throw is here: https://github.com/ipfs/helia/blob/main/packages/utils/src/pins.ts#L75

A couple of thoughts: 1) If the content already exists and/or is already pinned, is this really an error? The goal of the client is to have the content pinned, if it is already pinned, the client desire is satisfied already, not unsatisfiable. 2) If an error must be thrown, providing a specific error type or enumeration that could be reliably checked against would be helpful. Checking against an arbitrary message string seems fragile.

achingbrain commented 2 days ago

This seems reasonable, if a thing is pinned, and you try to pin it, it makes sense for it to be a no-op.

When adding content to Helia and setting the 'pin' option to true

What Helia API are you calling that accepts a pin option?