Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

feat!: add and connect missing context, remove RemovePinWithMode #23

Merged
merged 2 commits into from
Feb 22, 2023

Conversation

MichaelMure
Copy link

@MichaelMure MichaelMure commented Jan 16, 2023

Arguably, RemovePinWithMode could be removed as it seems to be unused.

Now that PinWithMode() takes a context and return an error, there is not that
much difference with Pin(). Those differences are:
- Pin() store the root node and fetch the graph if recursive
- Pin() accept an ipld.Node, PinWithMode() accept a CID (kinda meaningless)
- Pin() accept a "recurse" boolean, PinWithMode() accept a Mode, but only Direct and Recursive values

There is a case to be made to merge those or eliminate one.
@MichaelMure
Copy link
Author

Following discussion with @Jorropo, I made PinWithMode() return an error and in turn share most of the code with Pin()

Now that PinWithMode() takes a context and return an error, there is not that much difference with Pin(). Those differences are:

  • Pin() store the root node and fetch the graph if recursive
  • Pin() accept an ipld.Node, PinWithMode() accept a CID (kinda meaningless)
  • Pin() accept a "recurse" boolean, PinWithMode() accept a Mode, but only Direct and Recursive values

There is a case to be made to merge those or eliminate one.

@MichaelMure
Copy link
Author

As I merged Pin() and PinWithMode(), I noticed a difference in handling. This section was in Pin(), but absent in PinWithMode(). I have to say, I don't really understand what that does, and don't get what the comment wants to say. Maybe @gammazero could enlightens us?

@MichaelMure
Copy link
Author

Another difference I missed (and changed): when trying to directly pin when a recursive pin already existed, Pin() would return an error while PinWithMode() would proceed and create a duplicated pin.

I think the new behavior make sense: always return an error in that case.

@lidel lidel assigned lidel and Jorropo and unassigned lidel Jan 19, 2023
@MichaelMure
Copy link
Author

Corresponding PR in kubo: ipfs/kubo#9557

Copy link
Member

@hacdias hacdias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! The code looks good. Once ipfs/kubo#9557 passes, I'll merge and release this.

@hacdias hacdias changed the title Add and connect missing go context feat!: add and connect missing context, remove RemovePinWithMode Feb 22, 2023
@hacdias hacdias merged commit 9abb80f into ipfs:master Feb 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants