1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-05-17 15:06:47 +08:00

unixfs add: remove StdinName

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
Łukasz Magiera
2019-03-11 16:02:41 +01:00
parent 782b2d68ea
commit 964ef0b2e7
3 changed files with 8 additions and 14 deletions

View File

@ -189,7 +189,7 @@ You can now check what blocks have been created by:
var toadd files.Node = req.Files
name := ""
if !wrap {
if !wrap || pathName != "" {
it := req.Files.Entries()
if !it.Next() {
err := it.Err()
@ -204,7 +204,13 @@ You can now check what blocks have been created by:
}
_, dir := toadd.(files.Directory)
if !dir && pathName != "" {
name = pathName
if wrap {
toadd = files.NewSliceDirectory([]files.DirEntry{
files.FileEntry(pathName, toadd),
})
} else {
name = pathName
}
}
opts := []options.UnixfsAddOption{
@ -220,8 +226,6 @@ You can now check what blocks have been created by:
options.Unixfs.FsCache(fscache),
options.Unixfs.Nocopy(nocopy),
options.Unixfs.StdinName(pathName),
options.Unixfs.Progress(progress),
options.Unixfs.Silent(silent),
options.Unixfs.Events(events),

View File

@ -92,7 +92,6 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options
fileAdder.Silent = settings.Silent
fileAdder.RawLeaves = settings.RawLeaves
fileAdder.NoCopy = settings.NoCopy
fileAdder.Name = settings.StdinName
fileAdder.CidBuilder = prefix
switch settings.Layout {

View File

@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"os"
gopath "path"
"strconv"
@ -71,7 +70,6 @@ type Adder struct {
RawLeaves bool
Silent bool
Wrap bool
Name string
NoCopy bool
Chunker string
root ipld.Node
@ -418,13 +416,6 @@ func (adder *Adder) addFile(path string, file files.File) error {
return err
}
addFileInfo, ok := file.(files.FileInfo)
if ok {
if addFileInfo.AbsPath() == os.Stdin.Name() && adder.Name != "" {
path = adder.Name
adder.Name = ""
}
}
// patch it into the root
return adder.addNode(dagnode, path)
}