Documentation
¶
Overview ¶
Package watcher detects changes to protected files.
Editors save atomically (write temp file + rename), which drops watches on the file itself, so we watch parent directories, filter by name and debounce (~500ms) before hashing and creating a revision.
Package watcher turns filesystem events on protected files into sealed revisions, automatically.
Editors save atomically (write a temp file, rename it over the original), which drops a watch on the file itself. So we watch each protected file's *parent directory*, filter events by name, and debounce bursts of events before snapshotting. A periodic reconcile catches anything missed (e.g. events dropped while the machine slept) and picks up newly protected files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Debounce time.Duration // quiet period after the last event (default 500ms)
Reload time.Duration // how often to re-read the protected file list (default 10s)
Reconcile time.Duration // full snapshot of everything (default 5m)
// OnSnapshot is called for each file that got a new revision or problem.
OnSnapshot func(vault.SnapshotResult)
// OnError reports non-fatal errors (a directory that can't be watched…).
OnError func(error)
}
Options tune the watcher. Zero values get sensible defaults.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher watches protected files and snapshots them on change.