|
|
@ -210,7 +210,7 @@ func createSFTPConn(host, user string, cfg *options) (*sftp.Client, error) {
|
|
|
|
|
|
|
|
|
|
|
|
//defer conn.Close()
|
|
|
|
//defer conn.Close()
|
|
|
|
|
|
|
|
|
|
|
|
sftpConn, err := sftp.NewClient(conn.Client(), sftp.MaxPacket(64*1024))
|
|
|
|
sftpConn, err := sftp.NewClient(conn.Client(), sftp.MaxPacket(32*1024))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
//log.Fatal(err)
|
|
|
|
//log.Fatal(err)
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
@ -326,6 +326,7 @@ func upload(args []string, cfg *options) error {
|
|
|
|
|
|
|
|
|
|
|
|
sftpConn, err := createSFTPConn(host, user, cfg)
|
|
|
|
sftpConn, err := createSFTPConn(host, user, cfg)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.Debugf("create sftp failed: %s", err)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer sftpConn.Close()
|
|
|
|
defer sftpConn.Close()
|
|
|
@ -591,7 +592,7 @@ func passwordAuth() (string, error) {
|
|
|
|
// use this function has no problem
|
|
|
|
// use this function has no problem
|
|
|
|
//
|
|
|
|
//
|
|
|
|
func copyFile(w io.Writer, r io.Reader) error {
|
|
|
|
func copyFile(w io.Writer, r io.Reader) error {
|
|
|
|
buf := make([]byte, 34*1024)
|
|
|
|
buf := make([]byte, 32*1024)
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
n, err := r.Read(buf)
|
|
|
|
n, err := r.Read(buf)
|
|
|
|
if n > 0 {
|
|
|
|
if n > 0 {
|
|
|
|