Skip to content

Comments

feat(pinner): add CheckIfPinnedWithType for efficient checks with names#1035

Merged
lidel merged 3 commits intomainfrom
feat/pin-names-check-if-pinned
Sep 18, 2025
Merged

feat(pinner): add CheckIfPinnedWithType for efficient checks with names#1035
lidel merged 3 commits intomainfrom
feat/pin-names-check-if-pinned

Conversation

@lidel
Copy link
Member

@lidel lidel commented Sep 18, 2025

Adds CheckIfPinnedWithType method to the Pinner interface for efficient type-specific pin checks with optional name loading.

Why

ipfs pin ls <cid> --names in Kubo doesn't return pin names because the current API doesn't support fetching names for specific CIDs efficiently. This PR adds the missing functionality.

Changes

  • New CheckIfPinnedWithType(ctx, mode, includeNames, cids...) method
    • mode: which pin type to check (Recursive, Direct, Indirect, Any)
    • includeNames: whether to load pin names from datastore
  • CheckIfPinned now delegates to CheckIfPinnedWithType

Related

adds CheckIfPinnedWithType method to Pinner interface that allows checking
specific pin types with optional name loading. this enables efficient
pin operations like 'ipfs pin ls <cid> --names' without loading all pins.

- CheckIfPinned now delegates to CheckIfPinnedWithType for consistency

necessary for ipfs/js-kubo-rpc-client#343
@codecov
Copy link

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 78.23129% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.68%. Comparing base (1b799f0) to head (634cc18).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pinning/pinner/dspinner/pin.go 78.23% 20 Missing and 12 partials ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1035      +/-   ##
==========================================
+ Coverage   60.60%   60.68%   +0.08%     
==========================================
  Files         268      268              
  Lines       33460    33569     +109     
==========================================
+ Hits        20277    20372      +95     
- Misses      11513    11522       +9     
- Partials     1670     1675       +5     
Files with missing lines Coverage Δ
pinning/pinner/pin.go 32.35% <ø> (ø)
pinning/pinner/dspinner/pin.go 59.32% <78.23%> (+3.03%) ⬆️

... and 12 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

lidel added a commit to ipfs/kubo that referenced this pull request Sep 18, 2025
updates to use CheckIfPinnedWithType method from ipfs/boxo#1035,
enabling efficient pin name retrieval for 'ipfs pin ls <cid> --names'

- uses new CheckIfPinnedWithType from boxo for type-specific pin checks
- pin names are now returned when listing specific CIDs with --names flag
tests cover:
- type-specific pin checking (direct, recursive, indirect)
- pin name loading with includeNames flag
- multiple CIDs in single call
- edge cases (not pinned, internal mode, invalid mode)
- backward compatibility with CheckIfPinned
@lidel lidel force-pushed the feat/pin-names-check-if-pinned branch from f3c309e to 634cc18 Compare September 18, 2025 04:27
@lidel lidel marked this pull request as ready for review September 18, 2025 04:41
@lidel lidel requested a review from a team as a code owner September 18, 2025 04:41
@lidel lidel changed the title feat(pinner): add CheckIfPinnedWithType for efficient checks with names feat(pinner): add CheckIfPinnedWithType for efficient checks with names Sep 18, 2025
Copy link
Member Author

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Merging as per verbal during today's colo -- we will include this fix/optimization in Kubo 0.38.0-rc1.

@lidel lidel merged commit 0cd6062 into main Sep 18, 2025
18 checks passed
@lidel lidel deleted the feat/pin-names-check-if-pinned branch September 18, 2025 20:57
lidel added a commit that referenced this pull request Sep 18, 2025
Recursively pinned roots should not show as indirect.
Objects can be both directly and indirectly pinned.

Restores behavior from before PR #1035.
lidel added a commit that referenced this pull request Sep 19, 2025
…ion (#1039)

* fix(pinner): add context cancellation checks for indirect pins

- add context checks at start of each recursive pin traversal
- extract traverseIndirectPins helper to eliminate duplicate code
- add tests for context cancellation behavior

this fixes a pre-existing issue where indirect pin traversal never
checked for context cancellation, causing operations to continue even
after cancellation was requested. especially important for large pin
sets with many recursive pins.

* fix: indirect pin detection regression

Recursively pinned roots should not show as indirect.
Objects can be both directly and indirectly pinned.

Restores behavior from before PR #1035.

* docs: clarify pin type precedence in indirect checks

explain why recursive pins are excluded from indirect results while
direct pins are not. this asymmetry is intentional and preserved for
compatibility with established ipfs behavior.
lidel added a commit to ipfs/kubo that referenced this pull request Sep 19, 2025
* fix: use CheckIfPinnedWithType for pin ls with names

updates to use CheckIfPinnedWithType method from ipfs/boxo#1035,
enabling efficient pin name retrieval for 'ipfs pin ls <cid> --names'

- uses new CheckIfPinnedWithType from boxo for type-specific pin checks
- pin names are now returned when listing specific CIDs with --names flag

* test: add CLI tests for pin ls with names

tests cover:
- pin ls with specific CIDs returning names
- pin ls without CID listing all pins with names
- pin ls with --type and --names combinations
- JSON output with and without names
- pin update preserving names
- error cases (invalid CID, unpinned CID)

* docs: add pin name improvements to v0.38 changelog

covers fix for ipfs pin ls --names with specific CIDs
and RPC pin name leak fix

* fix(rpc): support pin names in Add()

passes the Name field from PinAddSettings to the API request

adds test to verify pin names work via RPC

* test: add coverage for pin names functionality

- test special characters, unicode, long names
- test concurrent operations
- test persistence across daemon restarts
- test garbage collection preservation
- fix indirect pin test logic

* chore: boxo@main with boxo#1039

* fix(pin): improve pin ls robustness and validation

- add nil check for n.Pinning with early fail-fast validation
- use pin.StringToMode() for consistent type validation
- add edge case tests for invalid types and unpinned CIDs
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

Successfully merging this pull request may close these issues.

1 participant