transfer

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDestinationIsDir = errors.New("cannot overwrite a directory with a file")

ErrDestinationIsDir mirrors cp's "cannot overwrite directory with non-directory". The commit step must check for it explicitly: the SFTP rename fallback removes the target first, which deletes an empty directory, and raw `mv -f` moves the temp file inside a directory and still exits 0.

View Source
var ErrParentSource = errors.New("recursive source must not end in '..'")

Functions

func ValidateRecursiveSource added in v0.5.0

func ValidateRecursiveSource(p string) error

ValidateRecursiveSource lets the CLI reject a ".." source before it connects. Both separators count because the remote OS is not known yet.

Types

type DestinationNotDirError added in v0.5.0

type DestinationNotDirError struct{ Path string }

func (*DestinationNotDirError) Error added in v0.5.0

func (e *DestinationNotDirError) Error() string

type Direction

type Direction int
const (
	Upload Direction = iota
	Download
	Relay
)

func (Direction) String

func (d Direction) String() string

type Endpoint

type Endpoint struct {
	Alias string
	Path  string
}

func (Endpoint) IsLocal

func (e Endpoint) IsLocal() bool

func (Endpoint) IsRemote

func (e Endpoint) IsRemote() bool

func (Endpoint) String

func (e Endpoint) String() string

type Engine

type Engine interface {
	Upload(ctx context.Context, localPath, remotePath string, progress ProgressFunc) (*Result, error)
	Download(ctx context.Context, remotePath, localPath string, progress ProgressFunc) (*Result, error)
	UploadRecursive(ctx context.Context, localDir, remoteDir string, progress ProgressFunc) (*Result, error)
	DownloadRecursive(ctx context.Context, remoteDir, localDir string, progress ProgressFunc) (*Result, error)
	Stat(ctx context.Context, remotePath string) (PathKind, error)
	ResolveDestination(ctx context.Context, remoteDst, name string) (string, error)
	PrepareRecursiveDestination(ctx context.Context, remoteDst, name string) (string, error)
	ListFiles(ctx context.Context, remoteDir string) ([]string, error)
	OpenRead(ctx context.Context, remotePath string) (io.ReadCloser, int64, error)
	OpenWrite(ctx context.Context, remotePath string) (io.WriteCloser, func() error, func(), error)
	Close() error
	Name() string
}

func NewEngine

func NewEngine(client *sshclient.Client, profile *remote.Profile, info func(string), options ...EngineOption) (Engine, error)

type EngineOption added in v0.3.0

type EngineOption func(*engineOptions)

func WithMkdirs added in v0.3.0

func WithMkdirs() EngineOption

type ParsedArgs

type ParsedArgs struct {
	Direction Direction
	Src       Endpoint
	Dst       Endpoint
}

func ParseArgs

func ParseArgs(src, dst string) (ParsedArgs, error)

type PathKind added in v0.5.0

type PathKind int
const (
	PathMissing PathKind = iota
	PathDir
	PathFile // exists and is not a directory
)

type ProgressFunc

type ProgressFunc func(info ProgressInfo)

type ProgressInfo

type ProgressInfo struct {
	File        string `json:"file"`
	Percent     int    `json:"percent"`
	Transferred int64  `json:"transferred"`
	Total       int64  `json:"total"`
	Speed       string `json:"speed"`
}

type ProgressTracker

type ProgressTracker struct {
	// contains filtered or unexported fields
}

func NewProgressTracker

func NewProgressTracker(file string, total int64, callback ProgressFunc) *ProgressTracker

func (*ProgressTracker) Finish

func (t *ProgressTracker) Finish()

func (*ProgressTracker) Update

func (t *ProgressTracker) Update(n int)

type RemoteParentMissingError added in v0.3.0

type RemoteParentMissingError struct {
	Path string
}

func (*RemoteParentMissingError) Error added in v0.3.0

func (e *RemoteParentMissingError) Error() string

type Result

type Result struct {
	Direction string `json:"direction"`
	Remote    string `json:"remote"`
	Local     string `json:"local,omitempty"`
	Size      int64  `json:"size"`
	Duration  string `json:"duration"`
	Engine    string `json:"engine"`
	Files     int    `json:"files"`
}

func RunRelay

func RunRelay(ctx context.Context, srcClient, dstClient *sshclient.Client, srcPath, dstPath string, srcProfile, dstProfile *remote.Profile, info func(string), progress ProgressFunc, options ...EngineOption) (*Result, error)

func RunRelayRecursive

func RunRelayRecursive(ctx context.Context, srcClient, dstClient *sshclient.Client, srcPath, dstPath string, srcProfile, dstProfile *remote.Profile, info func(string), progress ProgressFunc, options ...EngineOption) (*Result, error)

func (*Result) Pretty

func (r *Result) Pretty() string

Pretty renders a transfer result summary for output.Writer.Render in non-JSON mode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址