1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-05-20 00:18:12 +08:00

files2.0: no error from Entries

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
Łukasz Magiera
2018-11-24 04:51:43 +01:00
parent adc7490755
commit b10e718ab4
11 changed files with 15 additions and 18 deletions

View File

@ -85,7 +85,7 @@ environment variable:
f := req.Files f := req.Files
if f != nil { if f != nil {
it, _ := req.Files.Entries() it := req.Files.Entries()
if !it.Next() && it.Err() != nil { if !it.Next() && it.Err() != nil {
return it.Err() return it.Err()
} }

View File

@ -153,7 +153,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1.
return err return err
} }
it, _ := req.Files.Entries() it := req.Files.Entries()
if !it.Next() && it.Err() != nil { if !it.Next() && it.Err() != nil {
return it.Err() return it.Err()
} }

View File

@ -280,7 +280,7 @@ can't be undone.
} }
defer r.Close() defer r.Close()
it, _ := req.Files.Entries() it := req.Files.Entries()
if !it.Next() && it.Err() != nil { if !it.Next() && it.Err() != nil {
return it.Err() return it.Err()
} }

View File

@ -92,7 +92,7 @@ into an object of the specified format.
defer nd.Blockstore.PinLock().Unlock() defer nd.Blockstore.PinLock().Unlock()
} }
it, _ := req.Files.Entries() it := req.Files.Entries()
for it.Next() { for it.Next() {
if it.File() == nil { if it.File() == nil {
return fmt.Errorf("expected a regular file") return fmt.Errorf("expected a regular file")

View File

@ -769,7 +769,7 @@ stat' on the file or any of its ancestors.
return err return err
} }
it, _ := req.Files.Entries() it := req.Files.Entries()
if !it.Next() && it.Err() != nil { if !it.Next() && it.Err() != nil {
return it.Err() return it.Err()
} }

View File

@ -391,7 +391,7 @@ And then run:
return err return err
} }
it, _ := req.Files.Entries() it := req.Files.Entries()
if !it.Next() && it.Err() != nil { if !it.Next() && it.Err() != nil {
return it.Err() return it.Err()
} }

View File

@ -60,7 +60,7 @@ the limit will not be respected by the network.
return err return err
} }
it, _ := req.Files.Entries() it := req.Files.Entries()
if !it.Next() && it.Err() != nil { if !it.Next() && it.Err() != nil {
return it.Err() return it.Err()
} }
@ -110,7 +110,7 @@ Example:
return err return err
} }
it, _ := req.Files.Entries() it := req.Files.Entries()
if !it.Next() && it.Err() != nil { if !it.Next() && it.Err() != nil {
return it.Err() return it.Err()
} }

View File

@ -44,7 +44,7 @@ represent it.
return err return err
} }
it, _ := req.Files.Entries() it := req.Files.Entries()
if !it.Next() && it.Err() != nil { if !it.Next() && it.Err() != nil {
return it.Err() return it.Err()
} }

View File

@ -79,7 +79,7 @@ func (d *ufsDirectory) Close() error {
return nil return nil
} }
func (d *ufsDirectory) Entries() (files.DirIterator, error) { func (d *ufsDirectory) Entries() files.DirIterator {
fileCh := make(chan *ipld.Link, prefetchFiles) fileCh := make(chan *ipld.Link, prefetchFiles)
go func() { go func() {
d.dir.ForEachLink(d.ctx, func(link *ipld.Link) error { d.dir.ForEachLink(d.ctx, func(link *ipld.Link) error {
@ -98,7 +98,7 @@ func (d *ufsDirectory) Entries() (files.DirIterator, error) {
ctx: d.ctx, ctx: d.ctx,
files: fileCh, files: fileCh,
dserv: d.dserv, dserv: d.dserv,
}, nil }
} }
func (d *ufsDirectory) Size() (int64, error) { func (d *ufsDirectory) Size() (int64, error) {

View File

@ -567,8 +567,8 @@ func TestAdd(t *testing.T) {
return return
} }
origIt, _ := orig.(files.Directory).Entries() origIt := orig.(files.Directory).Entries()
gotIt, _ := got.(files.Directory).Entries() gotIt := got.(files.Directory).Entries()
for { for {
if origIt.Next() { if origIt.Next() {

View File

@ -416,10 +416,7 @@ func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) {
// Iterate over each top-level file and add individually. Otherwise the // Iterate over each top-level file and add individually. Otherwise the
// single files.File f is treated as a directory, affecting hidden file // single files.File f is treated as a directory, affecting hidden file
// semantics. // semantics.
it, err := tf.Entries() it := tf.Entries()
if err != nil {
return nil, err
}
for it.Next() { for it.Next() {
if err := adder.addFile(it.Name(), it.Node()); err != nil { if err := adder.addFile(it.Name(), it.Node()); err != nil {
return nil, err return nil, err
@ -537,7 +534,7 @@ func (adder *Adder) addDir(path string, dir files.Directory) error {
return err return err
} }
it, _ := dir.Entries() it := dir.Entries()
for it.Next() { for it.Next() {
fpath := gopath.Join(path, it.Name()) fpath := gopath.Join(path, it.Name())