Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

whyrusleeping
Copy link
Member

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

@ghost ghost assigned whyrusleeping Jul 3, 2018
@ghost ghost added the status/in-progress In progress label Jul 3, 2018
@whyrusleeping whyrusleeping changed the title Ipfs 0.4.16 release Allow files to be wrapped with a mutator during add Jul 3, 2018
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Contributor

@schomatis schomatis left a 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)
Copy link
Contributor

@schomatis schomatis Jul 6, 2018

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 :)

Copy link
Member

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)
Copy link
Contributor

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.)

@magik6k
Copy link
Member

magik6k commented Nov 28, 2018

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)

@eingenito eingenito mentioned this pull request Jan 14, 2019
@Stebalien
Copy link
Member

Closing in favor of a go-ipfs-files adapter. We can reopen this if that doesn't work.

@Stebalien Stebalien closed this Feb 28, 2019
@ghost ghost removed the status/in-progress In progress label Feb 28, 2019
@hacdias hacdias deleted the feat/add-wrap-exp branch May 9, 2023 10:55
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.

4 participants