small fixes and dependency updates
This commit is contained in:
parent
e95910d920
commit
96405e2521
238 changed files with 3599 additions and 3467 deletions
65
vendor/github.com/pkg/sftp/client.go
generated
vendored
65
vendor/github.com/pkg/sftp/client.go
generated
vendored
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
|
|
@ -226,15 +227,22 @@ func NewClientPipe(rd io.Reader, wr io.WriteCloser, opts ...ClientOption) (*Clie
|
|||
|
||||
if err := sftp.sendInit(); err != nil {
|
||||
wr.Close()
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error sending init packet to server: %w", err)
|
||||
}
|
||||
|
||||
if err := sftp.recvVersion(); err != nil {
|
||||
wr.Close()
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error receiving version packet from server: %w", err)
|
||||
}
|
||||
|
||||
sftp.clientConn.wg.Add(1)
|
||||
go sftp.loop()
|
||||
go func() {
|
||||
defer sftp.clientConn.wg.Done()
|
||||
|
||||
if err := sftp.clientConn.recv(); err != nil {
|
||||
sftp.clientConn.broadcastErr(err)
|
||||
}
|
||||
}()
|
||||
|
||||
return sftp, nil
|
||||
}
|
||||
|
|
@ -251,11 +259,11 @@ func (c *Client) Create(path string) (*File, error) {
|
|||
return c.open(path, flags(os.O_RDWR|os.O_CREATE|os.O_TRUNC))
|
||||
}
|
||||
|
||||
const sftpProtocolVersion = 3 // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02
|
||||
const sftpProtocolVersion = 3 // https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-02.txt
|
||||
|
||||
func (c *Client) sendInit() error {
|
||||
return c.clientConn.conn.sendPacket(&sshFxInitPacket{
|
||||
Version: sftpProtocolVersion, // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02
|
||||
Version: sftpProtocolVersion, // https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-02.txt
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -267,8 +275,13 @@ func (c *Client) nextID() uint32 {
|
|||
func (c *Client) recvVersion() error {
|
||||
typ, data, err := c.recvPacket(0)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
return fmt.Errorf("server unexpectedly closed connection: %w", io.ErrUnexpectedEOF)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
if typ != sshFxpVersion {
|
||||
return &unexpectedPacketErr{sshFxpVersion, typ}
|
||||
}
|
||||
|
|
@ -277,6 +290,7 @@ func (c *Client) recvVersion() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if version != sftpProtocolVersion {
|
||||
return &unexpectedVersionErr{sftpProtocolVersion, version}
|
||||
}
|
||||
|
|
@ -910,6 +924,45 @@ func (c *Client) MkdirAll(path string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// RemoveAll delete files recursively in the directory and Recursively delete subdirectories.
|
||||
// An error will be returned if no file or directory with the specified path exists
|
||||
func (c *Client) RemoveAll(path string) error {
|
||||
|
||||
// Get the file/directory information
|
||||
fi, err := c.Stat(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
// Delete files recursively in the directory
|
||||
files, err := c.ReadDir(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
// Recursively delete subdirectories
|
||||
err = c.RemoveAll(path + "/" + file.Name())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// Delete individual files
|
||||
err = c.Remove(path + "/" + file.Name())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return c.Remove(path)
|
||||
|
||||
}
|
||||
|
||||
// File represents a remote file.
|
||||
type File struct {
|
||||
c *Client
|
||||
|
|
@ -1660,7 +1713,7 @@ func (f *File) ReadFromWithConcurrency(r io.Reader, concurrency int) (read int64
|
|||
Handle: f.handle,
|
||||
Offset: uint64(off),
|
||||
Length: uint32(n),
|
||||
Data: b,
|
||||
Data: b[:n],
|
||||
})
|
||||
|
||||
select {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue