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

coreapi: remove Unixfs.Wrap #6123

Merged
merged 2 commits into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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