-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Allow files to be wrapped with a mutator during add #5184
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Wrap bool | ||
NoCopy bool | ||
Chunker string | ||
FileWrapper func(io.Reader) (io.Reader, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are all the field listed as modified? The FileWrapper
is the only new field right? Also, just to be extra annoying, could we add a comment explaining the function of the newly added field? I'm a strong believer in the broken windows theory :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's gofmt. It aligns everything.
@@ -114,6 +115,14 @@ func (adder *Adder) SetMfsRoot(r *mfs.Root) { | |||
|
|||
// Constructs a node from reader's data, and adds it. Doesn't pin. | |||
func (adder *Adder) add(reader io.Reader) (ipld.Node, error) { | |||
if adder.FileWrapper != nil { | |||
wr, err := adder.FileWrapper(reader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this is the single point of entry of a reader to the chunker right? (The other similar calls I'm finding in the code are for testing purposes only.)
After the files refactor (#5661) lands, it should be fairly easy to just wrap file interfaces to do this without having to modify the adder (and it will work via coreapi without touching internals) |
Closing in favor of a |
I'm playing around with different ways of importing files in a side project, and this small change allows me to encrypt or compress files on the fly.
License: MIT
Signed-off-by: Whyrusleeping why@ipfs.com