提交 a3bd2c23 作者: Kevin Atkinson

Add "--raw-leaves" option to "ipfs files"

License: MIT
Signed-off-by: 's avatarKevin Atkinson <k@kevina.org>
上级 7302c3ab
...@@ -43,6 +43,7 @@ operations. ...@@ -43,6 +43,7 @@ operations.
}, },
Options: []cmds.Option{ Options: []cmds.Option{
cmds.BoolOption("f", "flush", "Flush target and ancestors after write.").Default(true), cmds.BoolOption("f", "flush", "Flush target and ancestors after write.").Default(true),
cmds.BoolOption("raw-leaves", "Use raw blocks for newly created leaf nodes. (experimental)"),
}, },
Subcommands: map[string]*cmds.Command{ Subcommands: map[string]*cmds.Command{
"read": FilesReadCmd, "read": FilesReadCmd,
...@@ -598,6 +599,7 @@ stat' on the file or any of its ancestors. ...@@ -598,6 +599,7 @@ stat' on the file or any of its ancestors.
create, _, _ := req.Option("create").Bool() create, _, _ := req.Option("create").Bool()
trunc, _, _ := req.Option("truncate").Bool() trunc, _, _ := req.Option("truncate").Bool()
flush, _, _ := req.Option("flush").Bool() flush, _, _ := req.Option("flush").Bool()
rawLeaves, _, _ := req.Option("raw-leaves").Bool()
nd, err := req.InvocContext().GetNode() nd, err := req.InvocContext().GetNode()
if err != nil { if err != nil {
...@@ -620,6 +622,7 @@ stat' on the file or any of its ancestors. ...@@ -620,6 +622,7 @@ stat' on the file or any of its ancestors.
res.SetError(err, cmds.ErrNormal) res.SetError(err, cmds.ErrNormal)
return return
} }
fi.RawLeaves = rawLeaves
wfd, err := fi.Open(mfs.OpenWriteOnly, flush) wfd, err := fi.Open(mfs.OpenWriteOnly, flush)
if err != nil { if err != nil {
......
...@@ -23,6 +23,8 @@ type File struct { ...@@ -23,6 +23,8 @@ type File struct {
dserv dag.DAGService dserv dag.DAGService
node node.Node node node.Node
nodelk sync.Mutex nodelk sync.Mutex
RawLeaves bool
} }
// NewFile returns a NewFile object with the given parameters // NewFile returns a NewFile object with the given parameters
...@@ -79,6 +81,7 @@ func (fi *File) Open(flags int, sync bool) (FileDescriptor, error) { ...@@ -79,6 +81,7 @@ func (fi *File) Open(flags int, sync bool) (FileDescriptor, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
dmod.RawLeaves = fi.RawLeaves
return &fileDescriptor{ return &fileDescriptor{
inode: fi, inode: fi,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论