sync

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package sync provides a one-way sync engine that mirrors a pCloud directory tree to a local directory. Only files that are newer on pCloud are downloaded. Files deleted from pCloud are removed locally.

Package sync – TwoWaySyncer

Performs bidirectional sync between a local directory and a pCloud folder. On each run it pulls remote changes down first (same as Syncer), then watches the local file-system for events using fsnotify and mirrors those changes back to pCloud. A periodic pull pass keeps the local tree in sync with changes made to pCloud from other clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RunResult

type RunResult struct {
	Total      int // total files found on pCloud
	Downloaded int // files downloaded (new or updated)
	Deleted    int // local files removed (no longer on pCloud)
	Warnings   int // files that failed with a non-fatal error
}

RunResult summarises the outcome of a single sync pass.

type Syncer

type Syncer struct {
	// contains filtered or unexported fields
}

Syncer mirrors a pCloud directory tree to a local directory.

func New

func New(api *pcloud.API, cloudRoot, localRoot string, log io.Writer) *Syncer

New creates a Syncer. cloudRoot is the pCloud source path; localRoot is the destination directory on disk. Progress messages are written to log.

func (*Syncer) Run

func (s *Syncer) Run(ctx context.Context) (RunResult, error)

Run performs one sync pass and returns when it is finished.

func (*Syncer) Watch

func (s *Syncer) Watch(ctx context.Context, interval time.Duration) error

Watch calls Run repeatedly, sleeping interval between passes, until ctx is cancelled. It returns nil on clean shutdown.

type TwoWaySyncer added in v1.4.0

type TwoWaySyncer struct {
	// contains filtered or unexported fields
}

TwoWaySyncer mirrors files in both directions between a local directory and a pCloud folder. It always pulls the cloud state first to resolve any remote changes before acting on local events.

func NewTwoWay added in v1.4.0

func NewTwoWay(api *pcloud.API, cloudRoot, localRoot string, log io.Writer) *TwoWaySyncer

NewTwoWay creates a TwoWaySyncer. cloudRoot is the pCloud folder path; localRoot is the local directory. Progress messages are written to log.

func (*TwoWaySyncer) Run added in v1.4.0

func (t *TwoWaySyncer) Run(ctx context.Context, pullInterval time.Duration) error

Run performs an initial pull (pCloud → local), then enters a loop that:

  • watches the local file-system for changes and pushes them to pCloud;
  • periodically re-runs a pull pass to incorporate remote-only changes.

Run blocks until ctx is cancelled and returns nil on clean shutdown.

type Uploader added in v1.2.0

type Uploader struct {
	// contains filtered or unexported fields
}

Uploader syncs a local directory tree to a pCloud directory. Files absent on pCloud or locally newer are uploaded. Remote files no longer present locally are deleted from pCloud.

func NewUploader added in v1.2.0

func NewUploader(api *pcloud.API, localRoot, cloudRoot string, log io.Writer) *Uploader

NewUploader creates an Uploader. localRoot is the source on disk; cloudRoot is the pCloud destination path.

func (*Uploader) Run added in v1.2.0

func (u *Uploader) Run(ctx context.Context) (RunResult, error)

Run performs one upload sync pass and returns when it is finished. In RunResult: Downloaded counts uploaded files, Deleted counts remote deletions.

func (*Uploader) Watch added in v1.2.0

func (u *Uploader) Watch(ctx context.Context, interval time.Duration) error

Watch calls Run repeatedly, sleeping interval between passes, until ctx is cancelled. It returns nil on clean shutdown.

Jump to

Keyboard shortcuts

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