transfer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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)
	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)) (Engine, error)

type ParsedArgs

type ParsedArgs struct {
	Direction Direction
	Src       Endpoint
	Dst       Endpoint
}

func ParseArgs

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

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 Result

type Result struct {
	Direction string `json:"direction"`
	Remote    string `json:"remote"`
	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) (*Result, error)

func RunRelayRecursive

func RunRelayRecursive(ctx context.Context, srcClient, dstClient *sshclient.Client, srcDir, dstDir string, srcProfile, dstProfile *remote.Profile, info func(string), progress ProgressFunc) (*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