clone

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: GPL-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File

func File(dst, src string) error

File clones src to dst - including all clonable file attributes and xattr. File will use the best available CoW facilities provided by the OS and Filesystem. It will fall back to using copy via mmap(2) on systems that don't have CoW semantics.

func Metadata

func Metadata(dst, src string) error

CloneMetadata clones all the metadata from src to dst: the metadata is atime, mtime, uid, gid, mode/perm, xattr

func Tree

func Tree(dst, src string, opt ...Option) error

Tree clones the directory tree 'src' to 'dst' with options 'opt'. For example, an entry src/a will be cloned to dst/b. If dst exists, it must be a directory.

func UpdateMetadata

func UpdateMetadata(dst string, fi *fio.Info) error

UpdateMetadata writes new metadata of 'dst' from 'fi' The metadata that will be updated includes atime, mtime, uid/gid, mode/perm, xattr

Types

type Error

type Error struct {
	Op  string
	Src string
	Dst string
	Err error
}

Error represents the errors returned by CloneFile, CloneMetadata and UpdateMetadata

func (*Error) Error

func (e *Error) Error() string

Error returns a string representation of a clone Error

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying wrapped error

type FunnyEntry

type FunnyEntry struct {
	Name string // relative path name
	Src  *fio.Info
	Dst  *fio.Info
}

FunnyEntry captures an error where the source and destination are not the same type (eg src is a file and dst is a directory)

type FunnyError

type FunnyError struct {
	Funny []FunnyEntry
}

FunnyError represents a clone error that fails to clone a directory tree because there are one or more funny entries in the Src and Dst.

func (*FunnyError) Error

func (e *FunnyError) Error() string

Error returns a string representation of FunnyError

func (*FunnyError) Unwrap

func (e *FunnyError) Unwrap() error

Unwrap returns the underlying wrapped error; in our case this is a "leaf" error.

type Observer added in v0.4.1

type Observer interface {
	cmp.Observer

	Difference(d *cmp.Difference)

	// copy file src -> dst
	Copy(dst, src string)

	// delete file
	Delete(nm string)

	// create a hardlink src -> dst
	Link(dst, src string)

	MetadataUpdate(dst, src string)
}

Observer is invoked when the tree cloner makes progress. The Difference method is called just before starting the I/O operation. For every entry that is processed, Tree() invokes the Copy or Delete methods. The final metadata fixup step is tracked by the MetadataUpdate method.

func NopObserver added in v0.4.1

func NopObserver() Observer

NopObserver implements Observer and throws away all input. ie it's a no-op

type Option

type Option func(o *treeopt)

func WithIgnoreAttr

func WithIgnoreAttr(fl cmp.IgnoreFlag) Option

WithIgnoreAttr captures the attributes of fio.Info that must be ignored for comparing equality of two filesystem entries.

func WithIgnoreMissing added in v0.4.3

func WithIgnoreMissing(ign bool) Option

WithIgnoreMissing ensures that the cloner skips over files that disappear between the initial directory scan and concurrent differencing/copying.

func WithObserver added in v0.4.1

func WithObserver(ob Observer) Option

WithObserver uses 'ob' to report activities as the tree cloner makes progress

func WithWalkOptions

func WithWalkOptions(wo walk.Options) Option

WithWalkOptions uses 'wo' as the option for walk.Walk(); it describes a caller desired traversal of the file system with the requisite input and output filters

Jump to

Keyboard shortcuts

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