Documentation
¶
Overview ¶
Package contentdirs keeps content-addressed directories under a shared config root: one directory per build of an embedded bundle, named <base>-<hash>. PiG builds that share a config root (two installed versions, or stock PiG beside a Piglet Binary) each read and write only their own directory, so no build rewrites another's files or strands its extension builds.
A directory records its last use in its modification time. Eviction keeps the most recently used directories and never removes the caller's own, so a build that is still in use keeps its files. A process that reads a directory for as long as it lives, such as a session whose prompt names the pages of its documentation bundle, [Hold]s it: another build's eviction leaves a held directory, whatever its modification time.
Index ¶
Constants ¶
const ( // Keep is how many directories of one base survive eviction, the caller's own included. It covers a stock install, a Piglet Binary and an // upgrade in progress sharing one config root; each directory holds a few MiB. Keep = 4 )
Variables ¶
This section is empty.
Functions ¶
func Dirs ¶
Dirs returns the paths of the directories in parent named <base>-<16 hex digits>, most recently used first.
func Evict ¶
Evict removes base's directories in parent beyond the Keep most recently used, never own, and returns the removed paths. A directory some process [Hold]s stays, and does not count among the kept ones. The caller holds whatever lock excludes readers of those directories.
func Hold ¶
func Hold(dir string) (release func())
Hold records that this process reads dir until the returned release runs, which a process that holds a directory for as long as it lives never calls: Evict leaves a held directory, in this process and in every other, whatever its use time. The operating system releases the lease with the process, so a holder that dies leaves nothing behind but a lease file the next eviction removes with the directory. A directory with no lease file has no holder, so a build that never holds one (an older PiG) is evicted as before. Hold is best-effort, like Touch: a parent this user cannot write leaves the directory evictable, and release is then a no-op. Holding a directory twice holds it once.
Types ¶
This section is empty.