syncer

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package syncer drives a volume's sync cycle:

scan → commit local ops → pull peer journals → preserve conflicts →
materialize merged state → push blobs + own journal

Scanning always happens before pulling, so local edits are committed to the journal (and their content captured in the blob store) before any remote state can overwrite the working folder. Concurrent edits resolve deterministically last-writer-wins; the losing local version is preserved as a "<name>.bdrive-conflict-<device>-<time>" file that syncs like any other.

Index

Constants

View Source
const IgnoreFile = ".bdriveignore"

IgnoreFile is the per-folder opt-out list at the mount root. It uses a gitignore-style syntax and, unlike the .bdrive settings file, syncs like any other file so every device shares the same rules.

Variables

This section is empty.

Functions

func LogEntries

func LogEntries(st *store.Store, pathFilter string, limit int) ([]journal.Op, error)

LogEntries returns the volume history, newest first.

Types

type Filter

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

Filter decides which paths sync. A path syncs when it is not ignored and, if an include list is set, matches at least one include pattern.

Pattern syntax (a practical gitignore subset): one pattern per line, blank lines and #-comments skipped, `!` re-includes, a trailing `/` matches directories only, a `/` anywhere else anchors the pattern to the mount root (otherwise it matches at any depth), `*` matches within a path segment, `**` across segments, `?` a single character.

func (*Filter) PruneDir

func (f *Filter) PruneDir(rel string) bool

PruneDir reports whether a whole directory can be skipped during the scan walk. Pruning is conservative: never with `!` rules (a child could be re-included) or an include list (a deep child could match).

func (*Filter) Skip

func (f *Filter) Skip(rel string) bool

Skip reports whether a file path should not sync.

type Result

type Result struct {
	LocalOps     int  // local changes committed to the journal
	PulledOps    int  // ops received from other devices
	Conflicts    int  // conflict copies created
	Materialized int  // files written/removed in the working folder
	Pushed       bool // own journal/blobs uploaded
	Offline      bool // remote configured but unreachable this cycle
	OfflineErr   error
}

Result summarizes one sync cycle.

func (*Result) Activity

func (r *Result) Activity() bool

type Session

type Session struct {
	Folder  string
	MountID string // the stable project mount id from .bdrive/config.json
	Store   *store.Store
	Device  config.Device
	// Account is the signed-in user (from `bdrive login`); ops carry it so
	// history shows who changed what. Zero on offline/no-auth setups —
	// Device.Author remains the fallback identity.
	Account config.Settings
	Backend remote.Backend // nil = work offline
}

Session ties a working folder to its volume store and (optionally) remote.

func (*Session) Cycle

func (s *Session) Cycle(ctx context.Context) (*Result, error)

Cycle runs one full scan/sync/materialize pass under the volume lock.

Jump to

Keyboard shortcuts

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