--- a/vendor/github.com/spf13/afero/unionFile.go Wed Sep 18 19:17:42 2019 +0200
+++ b/vendor/github.com/spf13/afero/unionFile.go Sun Feb 16 18:54:01 2020 +0100
@@ -155,7 +155,8 @@
}
// Readdir will weave the two directories together and
-// return a single view of the overlayed directories
+// return a single view of the overlayed directories.
+// At the end of the directory view, the error is io.EOF if c > 0.
func (f *UnionFile) Readdir(c int) (ofi []os.FileInfo, err error) {
var merge DirsMerger = f.Merger
if merge == nil {
@@ -185,9 +186,23 @@
}
f.files = append(f.files, merged...)
}
- if c == -1 {
+
+ if c <= 0 && len(f.files) == 0 {
+ return f.files, nil
+ }
+
+ if f.off >= len(f.files) {
+ return nil, io.EOF
+ }
+
+ if c <= 0 {
return f.files[f.off:], nil
}
+
+ if c > len(f.files) {
+ c = len(f.files)
+ }
+
defer func() { f.off += c }()
return f.files[f.off:c], nil
}