Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
justin0mcateer opened this issue Sep 27, 2024 · 1 comment
Open

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

justin0mcateer opened this issue Sep 27, 2024 · 1 comment

Comments

@justin0mcateer
Copy link

justin0mcateer commented Sep 27, 2024

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
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants