Documentation
¶
Index ¶
- Variables
- func HasNumericRevisionSuffix(version string) bool
- func SplitRevision(version string) (string, int)
- type InstalledPackage
- type Store
- func (s *Store) AnyLockHeld() bool
- func (s *Store) Create(name, version string) (string, error)
- func (s *Store) IsInstalled(name, version string) bool
- func (s *Store) List() ([]InstalledPackage, error)
- func (s *Store) Remove(name, version string) error
- func (s *Store) ResolveDir(name, version string) string
- func (s *Store) StorePath(name, version string) (string, bool)
- func (s *Store) SweepTransient(maxAge time.Duration, dry bool) []string
Constants ¶
This section is empty.
Variables ¶
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
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
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 ¶
InstalledPackage represents a package in the store.
type Store ¶
type Store struct {
Root string
}
Store manages the package store directory.
func (*Store) AnyLockHeld ¶ added in v0.17.0
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 ¶
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 ¶
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 ¶
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
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
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
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.