-
-
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
Add full support for CidV1 in Files API and Dag Modifier #4026
Conversation
Tests are failing. Working on fixing. Also plan to add a "--raw-leaves" option to the files api. |
b2c7b6e
to
a740592
Compare
Support for raw leaves is done. I am going to tack on full CifV1 support and also support for setting a alternative hash function since they are very closely related. If necessary I can separate out CidV1 support into a new commit. |
dcff359
to
321b72d
Compare
Full support for CidV1 (including using an alternative hash function is now done) using the following strategy (slightly modified from #3921 (comment))
If any part of this is controversial or needs more though it can easily be factored out of this P.R. and into a new one. |
c9d16c5
to
872c7a7
Compare
@whyrusleeping this has been ready for review for awhile now The only outstanding issue if the I wrote a new utility |
core/commands/files/files.go
Outdated
root.Prefix = prefix | ||
} | ||
|
||
err = mfs.Mkdir(root, dirtomake, dashp, flush) |
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.
Hrm.. this is getting complicated. Its starting to feel like we need some sort of MkdirOpts
here that hold the dashp, flush, and prefix options for the operation.
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 would work. Are you thinking:
mfs.Mkdir(root, dirtomake, mfs.MkdirOpts{Dashp: dashp, Flush: flush, Prefix: prefix})
core/commands/files/files.go
Outdated
@@ -756,6 +794,69 @@ are run with the '--flush=false'. | |||
}, | |||
} | |||
|
|||
var FilesUpdateCmd = &cmds.Command{ |
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.
not yet sold on update
as the command name, but its an okay placeholder for now.
core/commands/files/files.go
Outdated
@@ -756,6 +794,69 @@ are run with the '--flush=false'. | |||
}, | |||
} | |||
|
|||
var FilesUpdateCmd = &cmds.Command{ | |||
Helptext: cmds.HelpText{ | |||
Tagline: "Change the cid version of hash function of the root node of a given path.", |
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.
s/of/or/
Also, given this description, maybe we should call the command re-cid
?
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.
How about chcid
?
core/commands/files/files.go
Outdated
Helptext: cmds.HelpText{ | ||
Tagline: "Change the cid version of hash function of the root node of a given path.", | ||
ShortDescription: ` | ||
Flush a given path to disk. This is only useful when other commands |
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.
ShortDescription needs fixing
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.
Oops, will fix.
core/commands/files/files.go
Outdated
`, | ||
}, | ||
Arguments: []cmds.Argument{ | ||
cmds.StringArg("path", false, false, "Path to flush. Default: '/'."), |
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.
update text here
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.
Oops, will fix.
core/commands/files/files.go
Outdated
func getFileHandle(r *mfs.Root, path string, create bool) (*mfs.File, error) { | ||
func getPrefix(req cmds.Request) (*cid.Prefix, error) { | ||
cidVer, cidVerSet, _ := req.Option("cid-version").Int() | ||
hashFunStr, hashFunSet, _ := req.Option("hash-fun").String() |
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'm not sure we should use hash-fun
. ipfs add just uses --hash
, i'm thinking we should be consistent.
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.
@whyrusleeping That won't work. The --hash
option is already used in one of the sub-commands and will create a conflict.
core/commands/files/files.go
Outdated
// ^^fixme: can't use just "hash" as the option name as the | ||
// conflicts with "--hash" usage by the stat command, this is | ||
// unfortunate as it creates an inconsistency with the "add" | ||
// that uses "hash" | ||
}, |
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.
@whyrusleeping here is the comment on why I can't use "hash" as the option name
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.
Can't we just have the --hash
option for stat be different from the one on the other commands?
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.
We could, if you are willing to change the interface for stat. That is something I didn't want to do.
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.
@whyrusleeping another option is to use --mhash
instead of --hash-fun
this is more specific (multi-hash) and is a good name for eventually making it a global option.
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 still don't think this is blocking anything. Stat is a separate command, it can have a flag that means something different, having those options on the ipfs files
command doesnt make sense for a lot of cases too. ipfs add
, which will at some point be moved under the ipfs files
command also uses --hash
. We need to stay consistent here.
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.
Stat is a separate command, it can have a flag that means something different
Not with the current API. Currently the --hash-fun
function is a global option for all ipfs files
command. The ipfs files stat
commandalso has the
--hashoption. It creates this error when the
stat` command is used:
$ ipfs files stat
Error: Option name 'hash' used multiple times
To resolve this conflict I need to either move the --hash
option into each of the subcommands, or rename the --stat
option in ipfs files stat
to something else. If I move the --hash
option to each of the subcommands I should likely move the --raw-leaves
and --cid-ver
option also to be consistent.
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.
Currently the --hash-fun function is a global option for all ipfs files command.
dont do that.
I need to either move the --hash option into each of the subcommands
Yes, do that.
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.
Done.
1a70c1d
to
28dcccd
Compare
@whyrusleeping I pushed some commits to address your feedback, I changed |
test/sharness/t0250-files-api.sh
Outdated
@@ -97,16 +97,17 @@ test_sharding() { | |||
} | |||
|
|||
test_files_api() { | |||
local EXTRA ARGS | |||
local EXTRA ARGS WRITE_ARGS |
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.
did you mean to call this RAW_LEAVES
?
Alright, this looks good to me. Going to need to rebase, and then it would be nice to have a few more of the codeclimate issues resolved before merging. |
5e96b61
to
14ff11b
Compare
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
30ddb19
to
54ab3d2
Compare
@whyrusleeping rebased and cleaned up some of the codeclimate issues |
54ab3d2
to
6d1d38c
Compare
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
6d1d38c
to
0182e59
Compare
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
Thanks @kevina! we're entering the brave new world of cidV1.. |
Your Welcome. I image there is still more work to do, but this should hopefully make CidV1 practical to use by default. :) |
Closes #3989 #3921
Status: #4026 (comment)