commands/http: Made MultiFileReader#Read more readable
Matt Bell committed
Nov 17, 2014 at 03:39 UTC
8900229579ff244c062ceb875aa528f0c3530049
1 file changed
+6
-11
commands/http/multifilereader.go
+6
-11
@@ -90,21 +90,16 @@ func (mfr *MultiFileReader) Read(buf []byte) (written int, err error) {
90
}
91
}
92
93
- var reader io.Reader
94
-
93
+ // if the buffer has something in it, read from it
94
if mfr.buf.Len() > 0 {
96
- // if the buffer has something in it, read from it
97
- reader = &mfr.buf
98
-
99
- } else if mfr.currentFile != nil {
100
- // otherwise, read from file data
101
- reader = mfr.currentFile
95
+ return mfr.buf.Read(buf)
96
}
97
104
- written, err = reader.Read(buf)
105
- if err == io.EOF && reader == mfr.currentFile {
98
+ // otherwise, read from file data
99
+ written, err = mfr.currentFile.Read(buf)
100
+ if err == io.EOF {
101
mfr.currentFile = nil
107
- return mfr.Read(buf)
102
+ return written, nil
103
}
104
return written, err
105
}