sync

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPlan

func ApplyPlan(ctx context.Context, srcFS FileSystem, dstFS FileSystem, plan *Plan, options ApplyOptions) error

func BuildBidirectionalPlans added in v0.9.0

func BuildBidirectionalPlans(leftFS FileSystem, rightFS FileSystem, leftRoot string, rightRoot string) (*Plan, *Plan, error)

func RunDaemonLoop added in v0.9.0

func RunDaemonLoop(ctx context.Context, interval time.Duration, fn func(context.Context) error) error

Types

type ApplyOptions

type ApplyOptions struct {
	Delete      bool
	DryRun      bool
	Permission  bool
	ParallelNum int
	Output      *output.Output
	SourceLabel string
	TargetLabel string
}

type CommandArgs

type CommandArgs struct {
	Delete         bool
	DryRun         bool
	Permission     bool
	Daemon         bool
	DaemonInterval time.Duration
	Bidirectional  bool
	ParallelNum    int
	Sources        []string
	Destination    string
}

func ParseCommandArgs

func ParseCommandArgs(args []string) (CommandArgs, error)

type DeleteScope

type DeleteScope struct {
	Path  string
	IsDir bool
}

type DesiredEntry

type DesiredEntry struct {
	SourcePath      string
	DestinationPath string
	RelPath         string
	Mode            fs.FileMode
	Size            int64
	ModTime         time.Time
	IsDir           bool
}

type FileSystem

type FileSystem interface {
	Expand(raw string) ([]string, error)
	Resolve(raw string) (string, error)
	Stat(path string) (fs.FileInfo, error)
	Walk(root string, fn func(path string, info fs.FileInfo) error) error
	Open(path string) (io.ReadCloser, error)
	OpenWriter(path string, perm fs.FileMode) (io.WriteCloser, error)
	MkdirAll(path string) error
	Remove(path string) error
	RemoveDir(path string) error
	Chmod(path string, mode fs.FileMode) error
	Chtimes(path string, atime, mtime time.Time) error
	Clean(path string) string
	Join(elem ...string) string
	Dir(path string) string
	Separator() string
}

func NewLocalFS

func NewLocalFS() (FileSystem, error)

func NewRemoteFS

func NewRemoteFS(client *sftp.Client, pwd string) FileSystem

type PathSpec

type PathSpec struct {
	IsRemote bool
	Hosts    []string
	Path     string
	Raw      string
}

func ParsePathSpec

func ParsePathSpec(arg string) (PathSpec, error)

type Plan

type Plan struct {
	Desired      map[string]DesiredEntry
	DeleteScopes []DeleteScope
}

func BuildPlan

func BuildPlan(srcFS FileSystem, dstFS FileSystem, sourceArgs []string, destination string) (*Plan, error)

type Sync

type Sync struct {
	Run *sshl.Run

	// ControlMasterOverride temporarily overrides the config value for this
	// command execution.
	ControlMasterOverride *bool
	DryRun                bool

	From SyncInfo
	To   SyncInfo

	Config         conf.Config
	Permission     bool
	Delete         bool
	Daemon         bool
	Bidirectional  bool
	DaemonInterval time.Duration
	ParallelNum    int

	Progress   *mpb.Progress
	ProgressWG *syncpkg.WaitGroup
}

func (*Sync) Start

func (s *Sync) Start()

type SyncConnect

type SyncConnect struct {
	Server  string
	Connect *sftp.Client
	Output  *output.Output
	Pwd     string
}

type SyncInfo

type SyncInfo struct {
	IsRemote bool
	Server   []string
	Path     []string
}

Jump to

Keyboard shortcuts

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