Documentation
¶
Overview ¶
Package tree is the filesystem side of sync: scanning a root into entries, staging content beside it, and applying changes by atomic rename.
Both ends use it. The endpoint runs it inside the sandbox; the controller runs it against the local root.
Index ¶
- Constants
- func CollectStale(root string) (uint32, error)
- func DigestFile(path string) (string, error)
- func IsEmpty(root string) (bool, error)
- func Marker(root string) (string, error)
- func ResolveWithin(root, rel string) (string, error)
- func StagingDir(root string) string
- func StateDir(root string) string
- func Transition(root string, staging *Staging, changes []*syncv1.Change) []*syncv1.Result
- func WriteMarker(root, sessionID string) error
- type Snapshot
- type Staging
Constants ¶
const ( // StateDirName holds everything sync keeps beside a root it is staging // into: the marker and the staging directory. One dotted directory, and it // excludes itself from every scan. StateDirName = ".agyn-sync" )
Variables ¶
This section is empty.
Functions ¶
func CollectStale ¶
CollectStale removes staging directories left by sessions that were terminated mid-transfer. Orphaned staged content is inert but occupies the workspace volume, so it is collected at handshake rather than left to accumulate.
func DigestFile ¶
DigestFile returns the hex sha256 of a file's contents, streamed rather than buffered — the endpoint shares the container's memory limit with the shell.
func IsEmpty ¶
IsEmpty reports whether a root holds anything sync would care about. The state directory does not count — a root holding only sync's own bookkeeping is empty as far as reconciliation is concerned.
func Marker ¶
Marker reads the root's session marker. An empty string with a nil error means the root carries none.
func ResolveWithin ¶
ResolveWithin refuses a path that would land outside the root. Paths arrive over a pipe from the other side, so a traversal is a real possibility and not merely a defensive check.
func StagingDir ¶
StagingDir is where content lands before being renamed into place. It sits under the root so the final rename is same-filesystem and therefore atomic.
func Transition ¶
Transition applies changes, returning one result per change. A failure on one path does not abort the batch: the whole point of per-path results is that a single unwritable file does not strand every other change in the cycle.
func WriteMarker ¶
WriteMarker records the session a root belongs to. Only sync writes one: a cp establishes no relationship, so planting a marker would assert something untrue and change how a later sync reads the root.
Types ¶
type Snapshot ¶
Snapshot is one side's view of a root.
func Scan ¶
Scan walks root and returns an entry per path. Per-path failures become problems rather than errors: one unreadable file must not stop the rest of the tree from syncing.
cache maps a relative path to a previously known (size, mtime, digest). An entry whose size and mtime are unchanged keeps its digest without being read.
type Staging ¶
type Staging struct {
// contains filtered or unexported fields
}
Staging holds content written beside a root, waiting to be renamed into it.
func OpenStaging ¶
OpenStaging creates the staging directory for a root.
func (*Staging) Has ¶
Has reports whether the content is already staged, so it need not be sent again. A digest names its own content, so presence is sufficient.