Avoid seeking os.Stdin in client-fs Put() (#1834)

This commit is contained in:
Anis Elleuch
2016-09-25 10:19:13 -07:00
committed by Harshavardhana
parent b404c7583b
commit 2b24a7b520
2 changed files with 9 additions and 3 deletions
+2 -3
View File
@@ -241,9 +241,8 @@ func (f *fsClient) Put(reader io.Reader, size int64, contentType string, progres
// Current file offset.
var currentOffset = partSt.Size()
// Reflect and verify if incoming reader implements ReaderAt.
readerAt, ok := reader.(io.ReaderAt)
if ok {
// Verify if incoming reader implements ReaderAt. Standard IO streams are excluded since their ReadAt() return illegal seek error
if readerAt, ok := reader.(io.ReaderAt); ok && !isStdIO(reader) {
// Notify the progress bar if any till current size.
if progress != nil {
if _, e = io.CopyN(ioutil.Discard, progress, currentOffset); e != nil {
+7
View File
@@ -18,7 +18,9 @@ package cmd
import (
"crypto/tls"
"io"
"math/rand"
"os"
"path/filepath"
"time"
@@ -58,3 +60,8 @@ func dumpTLSCertificates(t *tls.ConnectionState) {
console.Debugln(" >> Expires: " + cert.NotAfter.String())
}
}
// isStdIO checks if the input parameter is one of the standard input/output streams
func isStdIO(reader io.Reader) bool {
return reader == os.Stdin || reader == os.Stdout || reader == os.Stderr
}