Commit 89002295 authored by Matt Bell's avatar Matt Bell

commands/http: Made MultiFileReader#Read more readable

parent c9abc6b5
...@@ -90,21 +90,16 @@ func (mfr *MultiFileReader) Read(buf []byte) (written int, err error) { ...@@ -90,21 +90,16 @@ func (mfr *MultiFileReader) Read(buf []byte) (written int, err error) {
} }
} }
var reader io.Reader // if the buffer has something in it, read from it
if mfr.buf.Len() > 0 { if mfr.buf.Len() > 0 {
// if the buffer has something in it, read from it return mfr.buf.Read(buf)
reader = &mfr.buf
} else if mfr.currentFile != nil {
// otherwise, read from file data
reader = mfr.currentFile
} }
written, err = reader.Read(buf) // otherwise, read from file data
if err == io.EOF && reader == mfr.currentFile { written, err = mfr.currentFile.Read(buf)
if err == io.EOF {
mfr.currentFile = nil mfr.currentFile = nil
return mfr.Read(buf) return written, nil
} }
return written, err return written, err
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment