sync

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package sync copies files matching gitignore-style patterns between directories.

Index

Constants

This section is empty.

Variables

View Source
var ErrCloneUnsupported = errors.New("clone not supported")

ErrCloneUnsupported is returned by CloneTree / cloneFile when the platform or filesystem does not support the fast-clone path; callers fall back to io.Copy.

Functions

func CloneTree

func CloneTree(src, dst string) error

CloneTree copies src to dst as a CoW clone on platforms that support it (Darwin/APFS via clonefile, Linux via copy_file_range). Returns ErrCloneUnsupported when the platform or filesystem does not support the fast-clone path; callers should fall back to a regular copy.

Types

type Config

type Config struct {
	SourceDir string
	TargetDir string
	// Stage is an optional profiler hook; nil means no-op.
	// Call: done := cfg.Stage("name"); defer done()
	Stage   func(string) func()
	Workers int // concurrent copy goroutines; 0 = runtime.NumCPU()
}

Config controls where FileSyncer reads from and writes to.

type FileSyncer

type FileSyncer struct{}

FileSyncer is the production Syncer implementation.

func (FileSyncer) Sync

func (FileSyncer) Sync(patterns []string, cfg Config) (SyncResult, error)

type SyncResult

type SyncResult struct {
	Files int64
}

SyncResult holds file-transfer metrics from a Sync call.

type Syncer

type Syncer interface {
	Sync(patterns []string, cfg Config) (SyncResult, error)
}

Syncer copies files matching patterns from SourceDir to TargetDir. Patterns follow gitignore syntax: ** matches across directories, trailing / matches a directory and all its contents, and ! prefix negates a pattern. Files absent in SourceDir are silently skipped.

Jump to

Keyboard shortcuts

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