contentdirs

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 8 Imported by: 0

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.

Index

Constants

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

func Dirs(parent, base string) ([]string, error)

Dirs returns the paths of the directories in parent named <base>-<16 hex digits>, most recently used first.

func Evict

func Evict(parent, base, own string) ([]string, error)

Evict removes base's directories in parent beyond the Keep most recently used, never own, and returns the removed paths. The caller holds whatever lock excludes readers of those directories.

func Name

func Name(base, hash string) (string, error)

Name is the directory name of base's bundle with content hash, which must be at least 16 hex digits; only the first 16 are used.

func Touch

func Touch(dir string)

Touch records that dir was used now, unless it was recorded within the last hour. It is best-effort: a directory this user cannot write keeps its old time, which only makes it an earlier eviction candidate.

Types

This section is empty.

Jump to

Keyboard shortcuts

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