transport

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHashMismatch = errors.New("hash mismatch")

ErrHashMismatch reports that downloaded content did not hash to the expected value; the local file has not been replaced in that case.

Functions

func DownloadVerified added in v1.11.0

func DownloadVerified(t Transport, remoteRelPath, localPath, wantHash string, progress io.Writer) error

DownloadVerified downloads remoteRelPath and, when wantHash is non-empty, verifies the content hash *before* the file replaces localPath. On mismatch the local file is left untouched and ErrHashMismatch is returned. progress, when non-nil, is forwarded to the underlying Download (F12).

func FetchIndexFromRemote

func FetchIndexFromRemote(t Transport) (*index.Index, error)

func SyncIndexToRemote

func SyncIndexToRemote(t Transport, idx *index.Index) error

Types

type DirEntry

type DirEntry struct {
	Name  string
	IsDir bool
}

type RemoteInfo added in v1.11.0

type RemoteInfo struct {
	Size  int64
	Mtime time.Time
	IsDir bool
}

RemoteInfo is the actual server-side state of a path (as opposed to what the remote .ft/index.json claims). Mtime is zero when the server cannot report it (some FTP servers lack MDTM).

type Transport

type Transport interface {
	Connect() error
	Close() error
	Upload(localPath, remoteRelPath string, progress io.Writer) error
	Download(remoteRelPath, localPath string, progress io.Writer) error
	List(remoteDir string) ([]string, error)
	ListDir(remoteDir string) ([]DirEntry, error)
	Delete(remoteRelPath string) error
	Stat(remoteRelPath string) (RemoteInfo, error)
	FileExists(remoteRelPath string) (bool, int64, error)
	ReadFile(remoteRelPath string) ([]byte, error)
	WriteFile(remoteRelPath string, data []byte) error
	EnsureDir(remoteRelPath string) error
}

func NewTransport

func NewTransport(remote *config.Remote) (Transport, error)

Jump to

Keyboard shortcuts

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