Documentation
¶
Overview ¶
Package sftp provides an SFTP client that wraps SSH connection + SFTP session.
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) DeleteFile(remotePath string) error
- func (c *Client) Done() <-chan struct{}
- func (c *Client) Err() error
- func (c *Client) Open(remotePath string) (io.ReadCloser, error)
- func (c *Client) ReadDir(remotePath string) ([]*fs.FileEntry, error)
- func (c *Client) ReadFile(remotePath string) ([]byte, error)
- func (c *Client) Stat(remotePath string) (os.FileInfo, error)
- func (c *Client) Upload(remotePath string, src io.Reader) error
- func (c *Client) WalkFiles(remoteRoot string, fn func(path string) error) error
- func (c *Client) WalkFilesWithActivity(remoteRoot string, fn func(string) error, activity func() error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client holds an SSH connection and an SFTP session on top of it.
func (*Client) Close ¶
Close stops all monitoring and closes the transport, SFTP and auth resources. Concurrent calls wait for the same cleanup, including any in-flight probe.
func (*Client) DeleteFile ¶
DeleteFile removes a file on the remote host.
func (*Client) Done ¶
func (c *Client) Done() <-chan struct{}
Done closes once the connection has terminated and its monitor and resources have been released. All observers see the same terminal Err.
func (*Client) Open ¶
func (c *Client) Open(remotePath string) (io.ReadCloser, error)
Open opens a remote file for streaming reads.
func (*Client) ReadDir ¶
ReadDir reads one remote directory level. Directories are returned before files; both groups sorted alphabetically.
func (*Client) Upload ¶
Upload atomically writes everything src yields to a remote path, creating parent directories as needed. The existing target is replaced only after the staged file has been written and closed successfully, and keeps its permission bits. A target that is not a regular file is refused.
func (*Client) WalkFiles ¶
WalkFiles calls fn for every regular file under remoteRoot, recursively. Symlinks, FIFOs, sockets and devices are skipped, matching the local walker. A listing error on any directory is propagated rather than skipped: swallowing it would silently drop that subtree from the walk, so its files would never be compared or synced.