sync

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

Sync

Getting started

make build
make test-sync

Status

  • TBC Supports local file systems for Linux and OSX (Windows??).

Noteworthy

  • left sync and right sync are evetually consistent by nature: if the source changes while the sync is running, the next sync will re-align the destination.
  • two-way sync is more problematic by nature AND NO COMPLETELY SAFE SOLUTION IS AVAILABLE YET. Example: if side A changes during the sync, side B will not have the correct state. On subsequent sync, if side B was modifed, it would be synced to side A although it did not have the right state of sync. As a minimum, this must result in a conflict that should be resolved manually. Other options:
    • locking files at the start of sync and release them when after each file has been synced (limitation: folders can't be locked)
    • file system notifications (pCloud has support but other cloud providers may not)
    • check hash of source files before and after sync and rollback destination if the hash has changed. For folders, check the source folder has not moved after sync (this requires checking the folder's EntryID too so to guarantee it is the same folder), and rollback if changed

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FSReader

type FSReader interface {
	StreamFileData(ctx context.Context, fsEntry db.FSEntry) (<-chan []byte, <-chan error)
}

FSReader represents the behaviour of a file system reader.

type FSWriter

type FSWriter interface {
	MkDir(ctx context.Context, path string) error
	MkFile(ctx context.Context, path string, dataCh <-chan []byte) error
	RmDir(ctx context.Context, path string) error
	RmFile(ctx context.Context, path string) error
	MvDir(ctx context.Context, fromPath, toPath string) error
	MvFile(ctx context.Context, fromPath, toPath string) error
}

FSWriter represents the behaviour of a file system writer.

type OneWay

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

OneWay holds the from and to file systems and the mutation tracker needed to perform a one-way sync.

func NewOneWay

func NewOneWay(from FSReader, to FSWriter, fsTracker tracker) *OneWay

NewOneWay creates a new initialised OneWay struct.

func (*OneWay) Sync

func (s *OneWay) Sync(ctx context.Context) error

Sync performs the synchronisation of changes in the source file system to the destination file system.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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