Documentation
¶
Overview ¶
Package transfer implements the copy engine behind every provider's Upload and Download: atomic temp-and-rename delivery, tree walking with deepest-first directory-mode restoration, symlink and special-file policy, per-file progress, and prompt cancellation. A provider plugs an FS into each side of Copy and inherits the semantics the invoketest transfer contracts specify, rather than re-implementing them per transport.
Index ¶
- func Copy(ctx context.Context, src FS, srcPath string, dst FS, dstPath string, ...) error
- type DataFS
- type FS
- type HostFS
- func (HostFS) Abs(path string) (string, error)
- func (HostFS) Base(path string) string
- func (HostFS) Chmod(path string, mode fs.FileMode) error
- func (HostFS) Contains(root, path string) bool
- func (HostFS) CreateExclusive(path string) (WriteFile, error)
- func (HostFS) Dir(path string) string
- func (HostFS) Join(elem ...string) string
- func (HostFS) Lstat(path string) (fs.FileInfo, error)
- func (HostFS) Mkdir(path string) error
- func (HostFS) MkdirAll(path string) error
- func (HostFS) Open(path string) (ReadFile, error)
- func (HostFS) ReadDir(path string) ([]fs.FileInfo, error)
- func (HostFS) Readlink(path string) (string, error)
- func (HostFS) Remove(path string) error
- func (HostFS) Rename(oldPath, newPath string) error
- func (HostFS) Resolve(path string) (string, error)
- func (HostFS) SameFile(a, b fs.FileInfo) bool
- func (HostFS) Stat(path string) (fs.FileInfo, error)
- func (HostFS) Symlink(target, link string) error
- type LinkFS
- type MetaFS
- type PathFS
- type ReadFile
- type WriteFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
func Copy(ctx context.Context, src FS, srcPath string, dst FS, dstPath string, cfg invoke.TransferConfig) error
Copy copies srcPath on src to dstPath on dst after validating the transfer is safe: on a shared filesystem the paths must not alias each other, and a directory may not be copied into its own subtree.
The overlap guard applies only when both sides are the same filesystem, which is the only case where a path on one side means anything on the other. Two endpoints that happen to reach the same machine by different routes — an upload to the host the caller is running on, say — cannot be recognized as overlapping, and copying a directory into its own subtree that way will recurse into what it is writing.
Types ¶
type DataFS ¶
type DataFS interface {
Open(path string) (ReadFile, error)
// CreateExclusive creates path for writing, failing if it exists.
CreateExclusive(path string) (WriteFile, error)
// Rename moves oldPath over newPath, replacing any existing entry
// atomically.
Rename(oldPath, newPath string) error
Remove(path string) error
}
DataFS moves file content and whole entries.
type FS ¶
FS is one side of a transfer. Implementations must be comparable: Copy compares its two sides to decide whether same-file overlap guards apply.
type HostFS ¶
type HostFS struct{}
HostFS is the FS for the host's own filesystem — the local side of every provider's Upload and Download, and both sides of the local provider's.
func (HostFS) CreateExclusive ¶
CreateExclusive creates path for writing, failing if it exists.
func (HostFS) Mkdir ¶
Mkdir creates one directory at the conventional default mode; walked directories are chmod'd to their source's real mode afterward.
type LinkFS ¶
type LinkFS interface {
Symlink(target, link string) error
Readlink(path string) (string, error)
// Resolve canonicalizes path, following symbolic links.
Resolve(path string) (string, error)
}
LinkFS reads and writes symbolic links.
type MetaFS ¶
type MetaFS interface {
Lstat(path string) (fs.FileInfo, error)
Stat(path string) (fs.FileInfo, error)
ReadDir(path string) ([]fs.FileInfo, error)
Mkdir(path string) error
MkdirAll(path string) error
Chmod(path string, mode fs.FileMode) error
// SameFile reports whether two stat results name the same file, when
// the filesystem can tell; a side that cannot may always report false.
SameFile(a, b fs.FileInfo) bool
}
MetaFS reads and writes file metadata.
type PathFS ¶
type PathFS interface {
Abs(path string) (string, error)
Join(elem ...string) string
Dir(path string) string
Base(path string) string
// Contains reports whether path is root itself or lies under it.
Contains(root, path string) bool
}
PathFS is the path algebra of one side of a transfer. Each side applies its own separator rules, so a transfer between unlike systems stays correct on both.