mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-28 13:57:52 +08:00
Merge pull request #6123 from ipfs/coreapi/remove/wrap
coreapi: remove Unixfs.Wrap
This commit is contained in:
commit
7be3cd59f2
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
@ -69,7 +68,6 @@ type Adder struct {
|
||||
Trickle bool
|
||||
RawLeaves bool
|
||||
Silent bool
|
||||
Wrap bool
|
||||
NoCopy bool
|
||||
Chunker string
|
||||
root ipld.Node
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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 {
|
||||
|
||||
4
go.mod
4
go.mod
@ -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
|
||||
|
||||
6
go.sum
6
go.sum
@ -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=
|
||||
|
||||
Loading…
Reference in New Issue
Block a user