@cryptotaxi247 / kubo / commits / 964ef0b2e

unixfs add: remove StdinName

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Mar 11, 2019 at 16:02 UTC 964ef0b2e7eb57bbdbedb66c734fc46e7bd11f64
3 files changed +8 -14
core/commands/add.go
+8 -4
@@ -189,7 +189,7 @@ You can now check what blocks have been created by:
189
190 var toadd files.Node = req.Files
191 name := ""
192 - if !wrap {
192 + if !wrap || pathName != "" {
193 it := req.Files.Entries()
194 if !it.Next() {
195 err := it.Err()
@@ -204,7 +204,13 @@ You can now check what blocks have been created by:
204 }
205 _, dir := toadd.(files.Directory)
206 if !dir && pathName != "" {
207 - name = pathName
207 + if wrap {
208 + toadd = files.NewSliceDirectory([]files.DirEntry{
209 + files.FileEntry(pathName, toadd),
210 + })
211 + } else {
212 + name = pathName
213 + }
214 }
215
216 opts := []options.UnixfsAddOption{
@@ -220,8 +226,6 @@ You can now check what blocks have been created by:
226 options.Unixfs.FsCache(fscache),
227 options.Unixfs.Nocopy(nocopy),
228
223 - options.Unixfs.StdinName(pathName),
224 -
229 options.Unixfs.Progress(progress),
230 options.Unixfs.Silent(silent),
231 options.Unixfs.Events(events),
core/coreapi/unixfs.go
-1
@@ -92,7 +92,6 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options
92 fileAdder.Silent = settings.Silent
93 fileAdder.RawLeaves = settings.RawLeaves
94 fileAdder.NoCopy = settings.NoCopy
95 - fileAdder.Name = settings.StdinName
95 fileAdder.CidBuilder = prefix
96
97 switch settings.Layout {
core/coreunix/add.go
-9
@@ -5,7 +5,6 @@ import (
5 "errors"
6 "fmt"
7 "io"
8 - "os"
8 gopath "path"
9 "strconv"
10
@@ -71,7 +70,6 @@ type Adder struct {
70 RawLeaves bool
71 Silent bool
72 Wrap bool
74 - Name string
73 NoCopy bool
74 Chunker string
75 root ipld.Node
@@ -418,13 +416,6 @@ func (adder *Adder) addFile(path string, file files.File) error {
416 return err
417 }
418
421 - addFileInfo, ok := file.(files.FileInfo)
422 - if ok {
423 - if addFileInfo.AbsPath() == os.Stdin.Name() && adder.Name != "" {
424 - path = adder.Name
425 - adder.Name = ""
426 - }
427 - }
419 // patch it into the root
420 return adder.addNode(dagnode, path)
421 }