store

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInstalled = errors.New("package not installed")

ErrNotInstalled is returned when removing a package that does not exist.

Functions

func HasNumericRevisionSuffix added in v0.16.5

func HasNumericRevisionSuffix(version string) bool

HasNumericRevisionSuffix reports whether version ends in a "-<digits>" revision suffix. Distinguishes a bare semver-with- dev-tag like "0.16.2-dev.70+676b646" (no revision) from an explicit pinned form like "0.16.2-dev.70+676b646-1" (revision 1). resolveVersionFromEntries uses this to decide whether to scan for the highest revision on disk (bare → scan) or treat the version as an exact-match request (numeric suffix → exact). This is the canonical home for the classification — internal/generation, internal/registry, and cmd/gale route through it instead of keeping local copies.

func SplitRevision added in v0.16.5

func SplitRevision(version string) (string, int)

SplitRevision splits a "<base>-<N>" version into (base, N). A version without a numeric revision suffix is returned unchanged with revision 1 — the recipe default (an absent revision means 1, see recipe.Package.Full).

Types

type InstalledPackage

type InstalledPackage struct {
	Name    string
	Version string
}

InstalledPackage represents a package in the store.

type Store

type Store struct {
	Root string
}

Store manages the package store directory.

func NewStore

func NewStore(root string) *Store

NewStore creates a Store with the given root directory.

func (*Store) AnyLockHeld added in v0.17.0

func (s *Store) AnyLockHeld() bool

AnyLockHeld reports whether any per-package lock file under the store is currently flock-held — i.e. an install or build is in flight somewhere in the store. Used by gc to veto sweeps of scratch space that cannot be attributed to a specific package (gh#79).

func (*Store) Create

func (s *Store) Create(name, version string) (string, error)

Create creates the directory for a package version. It is idempotent; calling it for an existing version succeeds. Returns the full path to the version directory.

func (*Store) IsInstalled

func (s *Store) IsInstalled(name, version string) bool

IsInstalled checks if a package version exists in the store. Returns false for empty directories left by failed installs. When version ends with "-1" and the exact directory is absent, falls back to the bare version directory (back-compat).

func (*Store) List

func (s *Store) List() ([]InstalledPackage, error)

List returns all installed packages in the store.

func (*Store) Remove

func (s *Store) Remove(name, version string) error

Remove removes a package version from the store. Prefers exact match — callers that pass an on-disk name (e.g. from List) must get exactly that directory removed. Falls back to the back-compat patterns (bare dir for a "-1" request, highest-revision for a bare request) only when no exact match exists, so user-facing commands like `gale remove jq@1.8.1` still work regardless of which revision layout the store actually holds.

func (*Store) ResolveDir added in v0.16.5

func (s *Store) ResolveDir(name, version string) string

ResolveDir returns the on-disk store dir that (name, version) resolves to, applying the resolution order documented on resolveVersion. When nothing on disk matches, the literal <root>/<name>/<version> join is returned so callers can Stat it and report the missing path. This is the canonical resolver shared by internal/generation and cmd/gale — do not duplicate the resolution rules elsewhere.

func (*Store) StorePath added in v0.12.0

func (s *Store) StorePath(name, version string) (string, bool)

StorePath returns the absolute path to the store dir for (name, version) if one exists, with fallback to the bare version dir for "-1" suffixed requests. Returns ("", false) if no directory exists.

func (*Store) SweepTransient added in v0.17.0

func (s *Store) SweepTransient(maxAge time.Duration, dry bool) []string

SweepTransient removes crash-leftover transient entries (".build-*" staging dirs, "<version>.bak" backups, "<version>.stream" extract dirs) under every <root>/<name>/ directory. Only entries whose mtime is older than maxAge are touched, and a name dir whose lock file is concurrently flock-held is skipped entirely — an in-flight install of any version of that package may still be using its staging dirs (gh#78). Returns the swept paths; in dry mode, the paths that would be swept.

Jump to

Keyboard shortcuts

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