-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
core/corehttp: add support for posting directories to gateway #1543
Conversation
License: MIT Signed-off-by: Ethan Buchman <ethan@erisindustries.com>
@ebuchman gitcop is really strict about the format, lol |
fixed! thanks gitcop for your fine services. |
} | ||
|
||
// add a directory recursively | ||
func (i *gatewayHandler) addDirRecursive(file files.File) (*dag.Node, 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.
https://github.com/ipfs/go-ipfs/blob/master/core/commands/add.go#L329
...if common functions in corehttp and commands can be deduplicated?
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.
agreed this would be nice. I was hoping the addFile/addDir functions would have been exported from the core/commands
, but they're not and are tied to that params struct, so it would have taken more reorganization. Also the functions in core/commands
do more than we need for the gateway, like outputting progress bars, pinning, and ignoring hidden files (I've taken the opinion that if you send a tar ball, the whole thing will get added, hidden files included, and will not get pinned).
So, do you think we should add params for dealing with hidden files and pinning to the gateway?
Part of my hesitation in doing this (and in trying to use the functions in core/commands
) was issues like #1322 which seem to suggest there is much greater reorg coming to the gateway to support the api. I figured deduplication would come then. Thoughts?
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.
For outputting progress bars, I think this is handled specifically by a PostRun
function. So addDir can still be a common function.
That would be surprising to me if add
in commands does pinning, but doesn't when through gateway.
Similarly for the case of hidden files.
In either choice, I think they should be consistent in both commands and corehttp.
Maybe deduplication can be done later (i.e. add TODO: after blocking commits have been taken care of), if the functionality in this PR is more pressing.
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.
ok, you're right about progress bars. the commands version tho does do some outputing (there's this outputDag function) but I suppose we can switch over that and not do it from the gateway. The thing about pinning though, is that add from the cli does it by default. I don't think the gateway should replicate that, since the gateway is a hosted service which is presumably being offered by some remote kind soul to benefit whichever local poor soul doesn't have an ipfs daemon running locally. It would seem to be to be bad manners to have that kind remote gateway pin everything that anyone adds, and hence keep it all locally. My understanding of the gateway is that it is meant to be a service offering a conduit to the ipfs network, not a fully featured endpoint.
as for the hidden files flag, happy to add that. wheres the proper place to put a param like that in a post request? do i restructure the body or is it fine to go in the url?
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.
(I've taken the opinion that if you send a tar ball, the whole thing will get added, hidden files included, and will not get pinned).
So, do you think we should add params for dealing with hidden files and pinning to the gateway?
yeah, we've been thinking of adding a --pin
option to both ipfs add
and ipfs object put
(defaulted true for add, false for object put).
maybe gateway can follow same convention as API (?<opt-key>=<opt-val>
)
That would be surprising to me if add in commands does pinning, but doesn't when through gateway.
Similarly for the case of hidden files.
Agreed. add
should default to the same in both cases.
It would seem to be to be bad manners to have that kind remote gateway pin everything that anyone adds, and hence keep it all locally.
Yep, agreed. maybe a config can disallow default gateway auto-pin. and result can be returned in a header or in the output.
My understanding of the gateway is that it is meant to be a service offering a conduit to the ipfs network, not a fully featured endpoint.
Indeed. though users also use their own http gateways for local apps. eventually we'll want some capability based auth --- i.e. add works if you have the right token.
(will CR soon) is writable gateway broken atm, or did we fix that somewhere? cc @cryptix |
@jbenet nope, the IIRC that handler was a nasty implementation of what |
My two cents is that rather than shoehorning in an option (which will be awkward instead of using the entire |
further support for that opinion is the simplicity with which one can archive a directory (client side) while ignoring the hiddens: http://nerdboys.com/2008/10/27/how-to-create-a-tar-file-that-excludes-hidden-files-and-folders/ |
the gateway is becoming complex. may be worth breaking it into it's own repo. @whyrusleeping fix gx? I really want to start using it but every time i try, something goes horribly wrong. :( |
@jbenet i keep saying that i want ipns first, its not much fun without it |
Yeah gateway shouldn't pin by default. Though I initially wasn't aware that If gateway is to be put in separate repo, what about the common functions On Wed, Aug 5, 2015 at 9:01 PM, Jeromy Johnson notifications@github.com
. |
why is ipns needed? all the hashes are put into the package.json |
@jbenet but then you have to use the hashes in your import paths. |
This discussion is unrelated to gx. let's have it somewhere else. |
return | ||
} | ||
|
||
rootDir, err := unarchiveTarBall(tarBall) |
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 must every .tar.gzip archive be extracted? This makes the add and get not symmetric/reversible.
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.
maybe the input is tarred by default, so an intentionally added tar archive might be inside another tar?
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.
This assumes the uploader knows that the transport format is must be tar.gz, even for a tar.gz file.
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.
yeah :/ -- maybe if they're adding a file with our tools, it would be wrapped for them again. but good point. maybe should have a way to say "this is exactly what i want"
status here? I think we still want this. Although we can likely reopen as needed |
This is superseded by #1845 (the remaining issue here is to write the test case: can't curl POST directories, only list of files). |
No description provided.