1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-05-20 08:27:29 +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
if f != nil {
it, _ := req.Files.Entries()
it := req.Files.Entries()
if !it.Next() && it.Err() != nil {
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
}
it, _ := req.Files.Entries()
it := req.Files.Entries()
if !it.Next() && it.Err() != nil {
return it.Err()
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -567,8 +567,8 @@ func TestAdd(t *testing.T) {
return
}
origIt, _ := orig.(files.Directory).Entries()
gotIt, _ := got.(files.Directory).Entries()
origIt := orig.(files.Directory).Entries()
gotIt := got.(files.Directory).Entries()
for {
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
// single files.File f is treated as a directory, affecting hidden file
// semantics.
it, err := tf.Entries()
if err != nil {
return nil, err
}
it := tf.Entries()
for it.Next() {
if err := adder.addFile(it.Name(), it.Node()); err != nil {
return nil, err
@ -537,7 +534,7 @@ func (adder *Adder) addDir(path string, dir files.Directory) error {
return err
}
it, _ := dir.Entries()
it := dir.Entries()
for it.Next() {
fpath := gopath.Join(path, it.Name())