Avoid seeking os.Stdin in client-fs Put() (#1834)
This commit is contained in:
committed by
Harshavardhana
parent
b404c7583b
commit
2b24a7b520
+2
-3
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user