Skip to content

Commit b10e718

Browse files
committedDec 20, 2018
files2.0: no error from Entries
License: MIT Signed-off-by: Łukasz Magiera <[email protected]>
1 parent adc7490 commit b10e718

File tree

11 files changed

+15
-18
lines changed

11 files changed

+15
-18
lines changed
 

‎cmd/ipfs/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ environment variable:
8585

8686
f := req.Files
8787
if f != nil {
88-
it, _ := req.Files.Entries()
88+
it := req.Files.Entries()
8989
if !it.Next() && it.Err() != nil {
9090
return it.Err()
9191
}

‎core/commands/block.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1.
153153
return err
154154
}
155155

156-
it, _ := req.Files.Entries()
156+
it := req.Files.Entries()
157157
if !it.Next() && it.Err() != nil {
158158
return it.Err()
159159
}

‎core/commands/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ can't be undone.
280280
}
281281
defer r.Close()
282282

283-
it, _ := req.Files.Entries()
283+
it := req.Files.Entries()
284284
if !it.Next() && it.Err() != nil {
285285
return it.Err()
286286
}

‎core/commands/dag/dag.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ into an object of the specified format.
9292
defer nd.Blockstore.PinLock().Unlock()
9393
}
9494

95-
it, _ := req.Files.Entries()
95+
it := req.Files.Entries()
9696
for it.Next() {
9797
if it.File() == nil {
9898
return fmt.Errorf("expected a regular file")

‎core/commands/files.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ stat' on the file or any of its ancestors.
769769
return err
770770
}
771771

772-
it, _ := req.Files.Entries()
772+
it := req.Files.Entries()
773773
if !it.Next() && it.Err() != nil {
774774
return it.Err()
775775
}

‎core/commands/object/object.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ And then run:
391391
return err
392392
}
393393

394-
it, _ := req.Files.Entries()
394+
it := req.Files.Entries()
395395
if !it.Next() && it.Err() != nil {
396396
return it.Err()
397397
}

‎core/commands/object/patch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ the limit will not be respected by the network.
6060
return err
6161
}
6262

63-
it, _ := req.Files.Entries()
63+
it := req.Files.Entries()
6464
if !it.Next() && it.Err() != nil {
6565
return it.Err()
6666
}
@@ -110,7 +110,7 @@ Example:
110110
return err
111111
}
112112

113-
it, _ := req.Files.Entries()
113+
it := req.Files.Entries()
114114
if !it.Next() && it.Err() != nil {
115115
return it.Err()
116116
}

‎core/commands/tar.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ represent it.
4444
return err
4545
}
4646

47-
it, _ := req.Files.Entries()
47+
it := req.Files.Entries()
4848
if !it.Next() && it.Err() != nil {
4949
return it.Err()
5050
}

‎core/coreapi/unixfile.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (d *ufsDirectory) Close() error {
7979
return nil
8080
}
8181

82-
func (d *ufsDirectory) Entries() (files.DirIterator, error) {
82+
func (d *ufsDirectory) Entries() files.DirIterator {
8383
fileCh := make(chan *ipld.Link, prefetchFiles)
8484
go func() {
8585
d.dir.ForEachLink(d.ctx, func(link *ipld.Link) error {
@@ -98,7 +98,7 @@ func (d *ufsDirectory) Entries() (files.DirIterator, error) {
9898
ctx: d.ctx,
9999
files: fileCh,
100100
dserv: d.dserv,
101-
}, nil
101+
}
102102
}
103103

104104
func (d *ufsDirectory) Size() (int64, error) {

‎core/coreapi/unixfs_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ func TestAdd(t *testing.T) {
567567
return
568568
}
569569

570-
origIt, _ := orig.(files.Directory).Entries()
571-
gotIt, _ := got.(files.Directory).Entries()
570+
origIt := orig.(files.Directory).Entries()
571+
gotIt := got.(files.Directory).Entries()
572572

573573
for {
574574
if origIt.Next() {

‎core/coreunix/add.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,7 @@ func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) {
416416
// Iterate over each top-level file and add individually. Otherwise the
417417
// single files.File f is treated as a directory, affecting hidden file
418418
// semantics.
419-
it, err := tf.Entries()
420-
if err != nil {
421-
return nil, err
422-
}
419+
it := tf.Entries()
423420
for it.Next() {
424421
if err := adder.addFile(it.Name(), it.Node()); err != nil {
425422
return nil, err
@@ -537,7 +534,7 @@ func (adder *Adder) addDir(path string, dir files.Directory) error {
537534
return err
538535
}
539536

540-
it, _ := dir.Entries()
537+
it := dir.Entries()
541538
for it.Next() {
542539
fpath := gopath.Join(path, it.Name())
543540

0 commit comments

Comments
 (0)