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) {
}
}
var reader io.Reader
if mfr.buf.Len() > 0 {
// if the buffer has something in it, read from it
reader = &mfr.buf
} else if mfr.currentFile != nil {
// otherwise, read from file data
reader = mfr.currentFile
if mfr.buf.Len() > 0 {
return mfr.buf.Read(buf)
}
written, err = reader.Read(buf)
if err == io.EOF && reader == mfr.currentFile {
// otherwise, read from file data
written, err = mfr.currentFile.Read(buf)
if err == io.EOF {
mfr.currentFile = nil
return mfr.Read(buf)
return written, nil
}
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