feat: extract specific path, accept stdin as streaming input#384
feat: extract specific path, accept stdin as streaming input#384
Conversation
bb2448a to
e072d34
Compare
|
Latest commit adds An alternative would be to provide
|
|
this looks good! let me know when you want a full read through the code |
| if nf, ok := err.(interface{ NotFound() bool }); ok && nf.NotFound() { | ||
| fmt.Fprintf(c.App.ErrWriter, "data for directory entry not found: %s (skipping...)\n", name) | ||
| return 0, nil |
There was a problem hiding this comment.
Highlighting this while I think about it and so it doesn't get lost in the code move—in the case where you want to extract all, rather than a specific path, instead of erroring where a block load fails, it skips whatever it's failed to load. This needs more testing, and perhaps it's not feasable, because I've got an example where this partially works but then fails with an iterator overrun error which I don't yet understand. I'm guessing it's to do with sharded directory incompleteness but I need to work that out.
|
Added a big 'ol test script and some fixture data; ready for review @willscott |
(WIP: needs better testing, it works with the very limited test data I have at hand)
--path(-p) to extract just a specific unixfs path (and its children)-as a possible input for--file(-f) to read from stdin - the catch here is that it reads it into memory, so a large CAR is going to be a problem; but it will at least extract as the CAR blocks come in.So
cat foo.car | car extract -f - -p /my/specific/file.txtis a thing .. which will be even neater withlassie fetch <cid>/my/specific/file.txt -o -; when I make that a thing.I think I might have also fixed the macos-12 flaky test problem, maybe it's not a github.com/rogpeppe/go-internal problem after all but related to how macos-12 handles buffered file reads.