Skip to content

Commit

Permalink
Merge pull request #6123 from ipfs/coreapi/remove/wrap
Browse files Browse the repository at this point in the history
 coreapi: remove Unixfs.Wrap
  • Loading branch information
Stebalien authored Mar 25, 2019
2 parents 8c96e3b + 353dd67 commit 7be3cd5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 27 deletions.
1 change: 0 additions & 1 deletion core/coreapi/unixfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options
fileAdder.Out = settings.Events
fileAdder.Progress = settings.Progress
}
fileAdder.Wrap = settings.Wrap
fileAdder.Pin = settings.Pin && !settings.OnlyHash
fileAdder.Silent = settings.Silent
fileAdder.RawLeaves = settings.RawLeaves
Expand Down
27 changes: 3 additions & 24 deletions core/coreunix/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCLocker, ds ipld.DAG
Progress: false,
Pin: true,
Trickle: false,
Wrap: false,
Chunker: "",
}, nil
}
Expand All @@ -69,7 +68,6 @@ type Adder struct {
Trickle bool
RawLeaves bool
Silent bool
Wrap bool
NoCopy bool
Chunker string
root ipld.Node
Expand Down Expand Up @@ -144,8 +142,8 @@ func (adder *Adder) curRootNode() (ipld.Node, error) {
return nil, err
}

// if not wrapping, AND one root file, use that hash as root.
if !adder.Wrap && len(root.Links()) == 1 {
// if one root file, use that hash as root.
if len(root.Links()) == 1 {
nd, err := root.Links()[0].GetNode(adder.ctx, adder.dagService)
if err != nil {
return nil, err
Expand Down Expand Up @@ -288,7 +286,7 @@ func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) {
// directory, mfs root is the directory)
_, dir := file.(files.Directory)
var name string
if !adder.Wrap && !dir {
if !dir {
children, err := rootdir.ListNames(adder.ctx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -316,25 +314,6 @@ func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) {
return nil, err
}

// when adding wrapped directory, manually wrap here
if adder.Wrap && dir {
name = nd.Cid().String()

end := unixfs.EmptyDirNode()
if err := end.AddNodeLink(nd.Cid().String(), nd); err != nil {
return nil, err
}
nd = end

if err := adder.dagService.Add(adder.ctx, end); err != nil {
return nil, err
}

if err := outputDagnode(adder.Out, "", nd); err != nil {
return nil, err
}
}

// output directory events
err = adder.outputDirs(name, root)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ require (
github.com/ipfs/go-metrics-prometheus v0.0.2
github.com/ipfs/go-mfs v0.0.4
github.com/ipfs/go-path v0.0.3
github.com/ipfs/go-unixfs v0.0.3
github.com/ipfs/go-unixfs v0.0.4
github.com/ipfs/go-verifcid v0.0.1
github.com/ipfs/hang-fds v0.0.1
github.com/ipfs/interface-go-ipfs-core v0.0.4
github.com/ipfs/interface-go-ipfs-core v0.0.5
github.com/ipfs/iptb v1.4.0
github.com/ipfs/iptb-plugins v0.0.2
github.com/jbenet/go-is-domain v1.0.2
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,18 @@ github.com/ipfs/go-unixfs v0.0.1 h1:CTTGqLxU5+PRkkeA+w1peStqRWFD1Kya+yZgIT4Xy1w=
github.com/ipfs/go-unixfs v0.0.1/go.mod h1:ZlB83nMtxNMx4DAAE5/GixeKN1qHC+xspBksI7Q5NeI=
github.com/ipfs/go-unixfs v0.0.3 h1:09koecZaoJVoYy6Wkd/vo1lyQ4AdgAe83eJylQ7gAZw=
github.com/ipfs/go-unixfs v0.0.3/go.mod h1:FX/6aS/Xg95JRc6UMyiMdZeNn+N5VkD8/yfLNwKW0Ks=
github.com/ipfs/go-unixfs v0.0.4 h1:IApzQ+SnY0tfjqM7aU2b80CFYLZNHvhLmEZDIWr4e/E=
github.com/ipfs/go-unixfs v0.0.4/go.mod h1:eIo/p9ADu/MFOuyxzwU+Th8D6xoxU//r590vUpWyfz8=
github.com/ipfs/go-verifcid v0.0.1 h1:m2HI7zIuR5TFyQ1b79Da5N9dnnCP1vcu2QqawmWlK2E=
github.com/ipfs/go-verifcid v0.0.1/go.mod h1:5Hrva5KBeIog4A+UpqlaIU+DEstipcJYQQZc0g37pY0=
github.com/ipfs/hang-fds v0.0.1 h1:KGAxiGtJPT3THVRNT6yxgpdFPeX4ZemUjENOt6NlOn4=
github.com/ipfs/hang-fds v0.0.1/go.mod h1:U4JNbzwTpk/qP2Ms4VgrZ4HcgJGVosBJqMXvwe4udSY=
github.com/ipfs/interface-go-ipfs-core v0.0.4 h1:bMsRGLkttV8Y5C1VyeSePVxEatRGwS9pRdhNkWOt+cY=
github.com/ipfs/interface-go-ipfs-core v0.0.4/go.mod h1:AOUhAfBqYu3G6Ocn+Y6rgWUWjp2zdPZiCLr8QS1TEKg=
github.com/ipfs/interface-go-ipfs-core v0.0.5-0.20190325175850-33e0648669fb h1:kMcvq1emnbfUoWoHuq+m7JGO+rsuiN8jjuNB7bsR0WI=
github.com/ipfs/interface-go-ipfs-core v0.0.5-0.20190325175850-33e0648669fb/go.mod h1:VceUOYu+kPEy8Ev/gAhzXFTIfc/7xILKnL4fgZg8tZM=
github.com/ipfs/interface-go-ipfs-core v0.0.5 h1:lePQnz+SqDupeDrVWtzEIjZlcYAbG8tJLrttQWRmGRg=
github.com/ipfs/interface-go-ipfs-core v0.0.5/go.mod h1:VceUOYu+kPEy8Ev/gAhzXFTIfc/7xILKnL4fgZg8tZM=
github.com/ipfs/iptb v1.4.0 h1:YFYTrCkLMRwk/35IMyC6+yjoQSHTEcNcefBStLJzgvo=
github.com/ipfs/iptb v1.4.0/go.mod h1:1rzHpCYtNp87/+hTxG5TfCVn/yMY3dKnLn8tBiMfdmg=
github.com/ipfs/iptb-plugins v0.0.2 h1:JZp4h/+7f00dY4Epr8gzF+VqKITXmVGsZabvmZp7E9I=
Expand Down

0 comments on commit 7be3cd5

Please sign in to comment.