tree

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func CollectStale(root string) (uint32, error)

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

func DigestFile(path string) (string, error)

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

func IsEmpty(root string) (bool, error)

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

func Marker(root string) (string, error)

Marker reads the root's session marker. An empty string with a nil error means the root carries none.

func ResolveWithin

func ResolveWithin(root, rel string) (string, error)

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

func StagingDir(root string) string

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 StateDir

func StateDir(root string) string

StateDir is the sync state directory for a root.

func Transition

func Transition(root string, staging *Staging, changes []*syncv1.Change) []*syncv1.Result

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

func WriteMarker(root, sessionID string) error

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

type Snapshot struct {
	Entries  []*syncv1.Entry
	Problems []*syncv1.Problem
	Rehashed uint64
}

Snapshot is one side's view of a root.

func Scan

func Scan(root string, cache map[string]*syncv1.CachedDigest) (*Snapshot, error)

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

func OpenStaging(root string) (*Staging, error)

OpenStaging creates the staging directory for a root.

func (*Staging) Has

func (s *Staging) Has(digest string) bool

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.

func (*Staging) Path

func (s *Staging) Path(digest string) string

func (*Staging) Put

func (s *Staging) Put(digest string, src io.Reader, limit int64) (string, error)

Put streams content into staging and returns the digest actually computed over the bytes received, which the caller compares against what was promised. Nothing lands at its final name until the content is whole.

Jump to

Keyboard shortcuts

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