files2.0: no error from Entries
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Nov 24, 2018 at 04:51 UTC
b10e718ab4e032cdc806ca4903c5910cd51099db
11 files changed
+15
-18
cmd/ipfs/init.go
+1
-1
@@ -85,7 +85,7 @@ environment variable:
85
86
f := req.Files
87
if f != nil {
88
- it, _ := req.Files.Entries()
88
+ it := req.Files.Entries()
89
if !it.Next() && it.Err() != nil {
90
return it.Err()
91
}
core/commands/block.go
+1
-1
@@ -153,7 +153,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1.
153
return err
154
}
155
156
- it, _ := req.Files.Entries()
156
+ it := req.Files.Entries()
157
if !it.Next() && it.Err() != nil {
158
return it.Err()
159
}
core/commands/config.go
+1
-1
@@ -280,7 +280,7 @@ can't be undone.
280
}
281
defer r.Close()
282
283
- it, _ := req.Files.Entries()
283
+ it := req.Files.Entries()
284
if !it.Next() && it.Err() != nil {
285
return it.Err()
286
}
core/commands/dag/dag.go
+1
-1
@@ -92,7 +92,7 @@ into an object of the specified format.
92
defer nd.Blockstore.PinLock().Unlock()
93
}
94
95
- it, _ := req.Files.Entries()
95
+ it := req.Files.Entries()
96
for it.Next() {
97
if it.File() == nil {
98
return fmt.Errorf("expected a regular file")
core/commands/files.go
+1
-1
@@ -769,7 +769,7 @@ stat' on the file or any of its ancestors.
769
return err
770
}
771
772
- it, _ := req.Files.Entries()
772
+ it := req.Files.Entries()
773
if !it.Next() && it.Err() != nil {
774
return it.Err()
775
}
core/commands/object/object.go
+1
-1
@@ -391,7 +391,7 @@ And then run:
391
return err
392
}
393
394
- it, _ := req.Files.Entries()
394
+ it := req.Files.Entries()
395
if !it.Next() && it.Err() != nil {
396
return it.Err()
397
}
core/commands/object/patch.go
+2
-2
@@ -60,7 +60,7 @@ the limit will not be respected by the network.
60
return err
61
}
62
63
- it, _ := req.Files.Entries()
63
+ it := req.Files.Entries()
64
if !it.Next() && it.Err() != nil {
65
return it.Err()
66
}
@@ -110,7 +110,7 @@ Example:
110
return err
111
}
112
113
- it, _ := req.Files.Entries()
113
+ it := req.Files.Entries()
114
if !it.Next() && it.Err() != nil {
115
return it.Err()
116
}
core/commands/tar.go
+1
-1
@@ -44,7 +44,7 @@ represent it.
44
return err
45
}
46
47
- it, _ := req.Files.Entries()
47
+ it := req.Files.Entries()
48
if !it.Next() && it.Err() != nil {
49
return it.Err()
50
}
core/coreapi/unixfile.go
+2
-2
@@ -79,7 +79,7 @@ func (d *ufsDirectory) Close() error {
79
return nil
80
}
81
82
-func (d *ufsDirectory) Entries() (files.DirIterator, error) {
82
+func (d *ufsDirectory) Entries() files.DirIterator {
83
fileCh := make(chan *ipld.Link, prefetchFiles)
84
go func() {
85
d.dir.ForEachLink(d.ctx, func(link *ipld.Link) error {
@@ -98,7 +98,7 @@ func (d *ufsDirectory) Entries() (files.DirIterator, error) {
98
ctx: d.ctx,
99
files: fileCh,
100
dserv: d.dserv,
101
- }, nil
101
+ }
102
}
103
104
func (d *ufsDirectory) Size() (int64, error) {
core/coreapi/unixfs_test.go
+2
-2
@@ -567,8 +567,8 @@ func TestAdd(t *testing.T) {
567
return
568
}
569
570
- origIt, _ := orig.(files.Directory).Entries()
571
- gotIt, _ := got.(files.Directory).Entries()
570
+ origIt := orig.(files.Directory).Entries()
571
+ gotIt := got.(files.Directory).Entries()
572
573
for {
574
if origIt.Next() {
core/coreunix/add.go
+2
-5
@@ -416,10 +416,7 @@ func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) {
416
// Iterate over each top-level file and add individually. Otherwise the
417
// single files.File f is treated as a directory, affecting hidden file
418
// semantics.
419
- it, err := tf.Entries()
420
- if err != nil {
421
- return nil, err
422
- }
419
+ it := tf.Entries()
420
for it.Next() {
421
if err := adder.addFile(it.Name(), it.Node()); err != nil {
422
return nil, err
@@ -537,7 +534,7 @@ func (adder *Adder) addDir(path string, dir files.Directory) error {
534
return err
535
}
536
540
- it, _ := dir.Entries()
537
+ it := dir.Entries()
538
for it.Next() {
539
fpath := gopath.Join(path, it.Name())
540