lfs: only comnbine readers when necessary

This commit is contained in:
Taylor Blau 2016-11-04 14:25:06 -06:00
parent e450c68901
commit 482eba2176

@ -82,8 +82,14 @@ func copyToTemp(reader io.Reader, fileSize int64, cb progress.CopyCallback) (oid
return
}
multi := io.MultiReader(bytes.NewReader(by), reader)
size, err = tools.CopyWithCallback(writer, multi, fileSize, cb)
var from io.Reader = bytes.NewReader(by)
if int64(len(by)) < fileSize {
// If there is still more data to be read from the file, tack on
// the original reader and continue the read from there.
from = io.MultiReader(from, reader)
}
size, err = tools.CopyWithCallback(writer, from, fileSize, cb)
if err != nil {
return