Skip to content

Add car put-block command#629

Merged
willscott merged 4 commits into
ipld:masterfrom
parkan:master
Oct 16, 2025
Merged

Add car put-block command#629
willscott merged 4 commits into
ipld:masterfrom
parkan:master

Conversation

@parkan
Copy link
Copy Markdown
Contributor

@parkan parkan commented Oct 15, 2025

  • write counterpart to get-block
  • can set root on first block write (optional)

this is handy if you need to package up some blocks from an IPFS node (among other cases); ipfs dag export wants to walk the whole DAG, which doesn't work if you only need a shallow traversal

use like:

ipfs block get $CID1 | car put-block foo.car --set-root --version=2 --codec=dag-pb
ipfs block get $CID2 | car put-block foo.car --version=2 --codec=dag-pb

I tried to match the semantics to how the other write commands work

Copy link
Copy Markdown
Member

@willscott willscott left a comment

Choose a reason for hiding this comment

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

looks generally reasonable. a couple comments to think about, but no strongly held objection to this

Comment thread cmd/car/car Outdated
Comment thread cmd/car/car.go Outdated
Comment thread cmd/car/put.go Outdated
- write counterpart to get-block
- can set root on first block write (optional), not on appends
  (API/car standard limitation?)
@parkan
Copy link
Copy Markdown
Contributor Author

parkan commented Oct 15, 2025

ok, I've addressed the concerns:

  • removed binary checkin oopsie (should it be gitignored?)
  • v1 cars we do naive/cheap append
  • accept --cid param, if passed we parse codec out of that and verify that recomputed value matches; otherwise --codec must be passed

Copy link
Copy Markdown
Member

@willscott willscott left a comment

Choose a reason for hiding this comment

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

Looks great. since we don't have CI tests over this i want to pull and confirm the test script locally, but will plan to merge later today or tomorrow

@parkan
Copy link
Copy Markdown
Contributor Author

parkan commented Oct 15, 2025

the remaining nit is that the original commit should have been titled "Add car put-block...` but I think we can let that slide

Comment thread cmd/car/put.go
Co-authored-by: Rod Vagg <rod@vagg.org>
@willscott
Copy link
Copy Markdown
Member

Thanks again!

@willscott willscott merged commit badd2f7 into ipld:master Oct 16, 2025
12 of 13 checks passed
@parkan
Copy link
Copy Markdown
Contributor Author

parkan commented Oct 16, 2025

Looks great. since we don't have CI tests over this i want to pull and confirm the test script locally, but will plan to merge later today or tomorrow

BTW I'm not sure what you mean by this, I see my tests running in CI? https://github.com/ipld/go-car/actions/runs/18562918723/job/52916178584#step:13:5723

anyway thanks for merging, will be nice to be able to go install without replaces :)

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.

3 participants