runtimecell

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Overview

Package runtimecell builds and resolves packed extension runtime cells.

Index

Constants

View Source
const RetryCachedBuildCommand = "pig extensions cache prune --failures"

RetryCachedBuildCommand is the command that clears recorded build failures so the next start compiles again.

Variables

This section is empty.

Functions

func ArtifactIdentity

func ArtifactIdentity(entryDir string) (string, bool)

ArtifactIdentity returns the immutable digest recorded when an entry was published.

func BuildLispBaseImage

func BuildLispBaseImage(ctx context.Context, cacheRoot string) (string, error)

BuildLispBaseImage builds, or reuses, the image that runs an exact standalone Lisp script: the SDK with no member, loading the file named on its command line.

func BuildTimeout

func BuildTimeout() time.Duration

BuildTimeout is the time an extension build may take: PIG_CELL_BUILD_TIMEOUT as a Go duration, else ten minutes. pig additive (D20): the shared build cache and its build budget have no upstream equivalent.

func CurrentGoPackedCellEntry

func CurrentGoPackedCellEntry(cacheRoot, key string, extensions []GoExtension) (string, bool, error)

CurrentGoPackedCellEntry returns the valid cache entry selected by the same normalization and hash inputs as BuildGoPackedCell, without building it.

func CurrentLispPackedCellEntry

func CurrentLispPackedCellEntry(cacheRoot, key string, extensions []LispExtension) (string, bool, error)

CurrentLispPackedCellEntry returns the valid cache entry selected by the same normalization and hash inputs as BuildLispPackedCell, without building it.

func CurrentPythonPackedCellEntry

func CurrentPythonPackedCellEntry(cacheRoot, key string, extensions []PythonExtension) (string, bool, error)

CurrentPythonPackedCellEntry returns the valid cache entry selected by the same normalization and hash inputs as BuildPythonPackedCell, without building it.

func CurrentRustPackedCellEntry

func CurrentRustPackedCellEntry(cacheRoot, key string, extensions []RustExtension) (string, bool, error)

CurrentRustPackedCellEntry returns the valid cache entry selected by the same normalization and hash inputs as BuildRustPackedCell, without building it.

func ExtPackageName

func ExtPackageName(name string) string

ExtPackageName returns a deterministic import alias for a generated packed or fused extension registry.

func GoBuildCgoEnv

func GoBuildCgoEnv(goos, goarch string) string

GoBuildCgoEnv returns the CGO_ENABLED entry for building a Go extension for goos/goarch. Extensions build without cgo, except on Android for every architecture but arm64, where Go links executables externally even without cgo (internal/platform.MustLinkExternal) and `go build` with CGO_ENABLED=0 fails with "requires external (cgo) linking".

func GoModuleSourceDigest

func GoModuleSourceDigest(root string) (string, error)

GoModuleSourceDigest is hashGoModule's identity as a digest for build locks: an error identity is returned as an error.

func GoSDKPathOverride

func GoSDKPathOverride(root string) string

GoSDKPathOverride returns an extension module's explicit local SDK replace, judging a retired staged SDK against the config root the environment names.

func HasCacheEntries

func HasCacheEntries(cacheRoot string) (bool, error)

HasCacheEntries reports whether PruneCaches and InspectCache would classify at least one entry under cacheRoot.

func IsCacheDirectory

func IsCacheDirectory(dir string) (bool, error)

IsCacheDirectory reports whether the directory dir is the root of a tree marked with the CACHEDIR.TAG signature: build output that a build running beside a source hash fills and empties, never source. Cargo marks every target directory it creates, atomically with the directory itself.

func MarkArtifactUsed

func MarkArtifactUsed(artifactPath string, now time.Time) error

func ReadDirShared

func ReadDirShared(dir string) ([]fs.DirEntry, error)

ReadDirShared lists the directory dir in name order, like os.ReadDir. On Windows it opens the directory with every share mode, FILE_SHARE_DELETE included, which os.ReadDir's open does not: a handle without FILE_SHARE_DELETE makes any other process's delete or rename of that directory fail with a sharing violation while it is open, and a directory that another process holds open for delete (every os.RemoveAll of it does, for an instant) makes that open fail with one. A source hash walks trees that a build running beside it fills and empties, so it must neither block the build nor fail on it.

func ResolvePrebuilt

func ResolvePrebuilt(req PrebuiltRequest) (string, bool)

ResolvePrebuilt exposes the process-wide prebuilt-cell resolver to other host packages (e.g. the source-mode subprocess builder). Returns ("", false) when no resolver is registered, so stock pig behavior is unchanged.

func ResolveQuicklisp

func ResolveQuicklisp(ctx context.Context, cacheRoot string, names []string) ([]string, error)

ResolveQuicklisp makes the source of every Quicklisp system the named systems need available under cacheRoot and returns the directories that hold their .asd files. names are the systems the extension's own source depends on that ASDF cannot find. It fetches only through the pinned dist, honours PIG_OFFLINE, and fails closed on any mismatch.

func RetiredStagedSDK

func RetiredStagedSDK(dir, stagedDir string) bool

RetiredStagedSDK reports whether dir, an extension's local SDK replace or path dependency, names an SDK an earlier build of the host staged rather than the one staged now. stagedDir is the current staging directory for the language (pigsdklock.StagedSDKDir); its parent, <config root>/state/pigsdk, is the staging area. dir is retired when, after resolving symlinks, it lies inside that area but outside stagedDir. Staging never deletes an older directory, so a link an author made to it keeps resolving after an update and would build the extension against an SDK the running host no longer speaks. A stagedDir outside that layout disables the check.

func RustSDKPathOverride

func RustSDKPathOverride(root string) string

RustSDKPathOverride returns an extension crate's explicit local SDK path, judging a retired staged SDK against the config root the environment names.

func SetDriftClassifier

func SetDriftClassifier(classify DriftClassifier)

SetDriftClassifier installs the classification of failed Go builds as SDK drift; the pig command installs it from an init function. The classification lives in extensions/sdk/upgrade, whose package also holds the extension upgrade rewrites and with them go/types: a program that embeds the extension host without the upgrade command does not link either, and a Go build that fails reports the compiler's message as it is. Call it before any build, from an init function.

func SetPrebuiltResolver

func SetPrebuiltResolver(r PrebuiltResolver)

SetPrebuiltResolver installs the process-wide prebuilt-cell resolver, or nil to restore the default from-source behavior.

func SocketEnvName

func SocketEnvName(name string) string

SocketEnvName returns the environment variable used to pass one extension's socket into a packed-cell runner.

func StageLegacyGoSDK

func StageLegacyGoSDK(sdkRoot, dst string) error

StageLegacyGoSDK copies the SDK module and its subpackages into dst under the legacy import path. Self-imports follow the alias, including internal packages. Authored SDK sources remain untouched. pig additive (D19): legacy Go imports use the running host's SDK contract.

func StrippedSDKError

func StrippedSDKError(lang string) error

StrippedSDKError reports the error for a language ("go", "rust" or "python") whose embedded extension SDK this process runs without, or nil. pig additive (D92): a Piglet strips an extension SDK, so a build that needs the SDK this binary would stage reports the strip instead of a missing SDK. Stock PiG strips none.

func TouchUsage

func TouchUsage(entryDir string, now time.Time) error

func ValidEntry

func ValidEntry(entryDir string, want EntryIdentity) (string, bool)

ValidEntry reports whether a cache directory contains a complete artifact published for want on this platform.

func WalkDirShared

func WalkDirShared(root string, fn fs.WalkDirFunc) error

WalkDirShared is filepath.WalkDir with ReadDirShared as its directory listing, with the same order and the same handling of the errors fn returns.

func WithGoBuildModule

func WithGoBuildModule(ctx context.Context, extension GoExtension, preferredSDKRoot string, use func(GoBuildModule) error) error

WithGoBuildModule stages the module a build of extension compiles, holds the SDK against a restage while use runs, and removes the module after. It compiles nothing.

pig additive (D109): pig extension upgrade reads the types of an extension the way its build does.

func WriteRustWarmCell

func WriteRustWarmCell(dir, sdkRoot string) error

WriteRustWarmCell writes a Rust cell crate with no extensions into dir: the manifest and the lock copy a real cell gets, and an empty main. Building it fills a Cargo target with the units every cell of that SDK shares, pig-sdk included (Cargo keys a path dependency's unit on its path), so make test-warm seeds the cell's own unit and not a lookalike.

Types

type BuildFailure

type BuildFailure struct {
	// Summary is one line naming what failed.
	Summary string
	// Cause is the part of Summary that does not depend on which extension
	// failed. Failures with equal Cause have one root cause.
	Cause string
	// Log is the file holding the complete compiler output, or empty when it
	// could not be written.
	Log string
	// Cached is set when the failure is a recorded earlier one: the build did not
	// run again because none of its inputs changed.
	Cached bool
	// Drift lists the SDK changes the extension was written for the old shape of. It is empty unless every compile error is such a change.
	Drift []Drift
	// contains filtered or unexported fields
}

BuildFailure is a compiler failure reduced to what a person reads: one line, a cause that failures of the same kind share, and the file that holds the full compiler output. The compiler output never travels in the error, so a failed build cannot fill a terminal.

pig additive (D20): PiG compiles extensions, which Pi does not, so Pi has no counterpart to this report.

func GoBuildFailure

func GoBuildFailure(cacheRoot, logKey, dir string, tc toolchain.GoToolchain, buildErr error, output, generatedMod []byte) (failure *BuildFailure, recordable bool)

GoBuildFailure reports a failed `go build` run with tc in dir: it classifies the output, writes the complete output to a log under cacheRoot, and remembers a broken toolchain for this process. recordable reports whether the same inputs fail again, so the caller may record the failure against them.

func KnownGoToolchainFailure

func KnownGoToolchainFailure(tc toolchain.GoToolchain) (*BuildFailure, bool)

KnownGoToolchainFailure returns the recorded release mismatch of tc, if a build in this process already met it.

func LispBuildFailure

func LispBuildFailure(cacheRoot, logKey, dir string, buildErr error, output []byte, run BuildRun) (failure *BuildFailure, recordable bool)

LispBuildFailure reports a failed sbcl image build: one summary line, and the complete output in a log under cacheRoot. recordable reports whether the same inputs fail again: a compile or load error the build script reported (a failure of the extension's source), not a toolchain or I/O failure.

func RustBuildFailure

func RustBuildFailure(cacheRoot, logKey, dir string, buildErr error, output []byte, run BuildRun) (failure *BuildFailure, recordable bool)

RustBuildFailure reports a failed `cargo build` run in dir: one summary line, and the complete output in a log under cacheRoot. recordable reports whether the same inputs fail again. That holds for a rustc diagnostic, which names a source position. Dependency resolution and network failures do not, so they are reported but never recorded. A run that left no diagnostic (cargo or rustc killed by a signal, a context that ended) says how it ended: the exit status or signal, the process cargo reports as not exiting successfully, how long it ran and whether its context had ended.

func (*BuildFailure) Detail

func (e *BuildFailure) Detail(lead string) string

Detail is the parenthetical that points at the log and, for a recorded failure, at the way to retry. lead is placed inside it before those, for example the extensions a group covers.

func (*BuildFailure) Error

func (e *BuildFailure) Error() string

func (*BuildFailure) Unwrap

func (e *BuildFailure) Unwrap() error

Unwrap returns the error the failure was recorded from, or nil for a report that was built directly or read from the cache.

type BuildRun

type BuildRun struct {
	// Elapsed is the time from starting the command to its exit.
	Elapsed time.Duration
	// ContextErr is the error of the context the command ran under, nil when it had not ended.
	ContextErr error
}

BuildRun is what the caller knows about a `cargo build` run that the command's output does not say: how long it ran and whether its context had ended.

type CacheClass

type CacheClass string
const (
	CacheActive           CacheClass = "active"
	CacheCurrent          CacheClass = "current"
	CacheBuilding         CacheClass = "building"
	CacheInactiveRetained CacheClass = "inactive-retained"
	CacheInactiveExpired  CacheClass = "inactive-expired"
	CacheInvalid          CacheClass = "incomplete/invalid"
)

type CacheEntry

type CacheEntry struct {
	Path     string     `json:"path"`
	Class    CacheClass `json:"class"`
	Bytes    int64      `json:"bytes"`
	LastUsed int64      `json:"lastUsed,omitempty"`
	Reason   string     `json:"reason,omitempty"`
	// Failure marks a recorded build failure, not a built artifact.
	Failure bool `json:"failure,omitempty"`
	// contains filtered or unexported fields
}

type CacheLifecycleOptions

type CacheLifecycleOptions struct {
	// Context stops the collection between entries and inside an entry's tree. Nil means no cancellation.
	Context          context.Context
	CacheRoot        string
	Current          map[string]struct{}
	LiveFingerprints map[string]struct{}
	Now              func() time.Time
	Retention        time.Duration
	CrashGrace       time.Duration
	MaxSize          *int64
	// RemoveFailures removes every recorded build failure, so the next start
	// compiles those cells again. A failure whose build is in progress stays.
	RemoveFailures bool
	// Unsized skips reading the size of every file in every entry: Bytes, TotalBytes, ProtectedBytes and RemovedBytes stay zero. A caller that reads none of them sets it, because the sizes cost one stat per cached file. MaxSize needs the sizes and overrides it.
	Unsized   bool
	DryRun    bool
	Rename    func(string, string) error
	RemoveAll func(string) error
}

type CacheReport

type CacheReport struct {
	Entries      []CacheEntry       `json:"entries"`
	ByClass      map[CacheClass]int `json:"byClass"`
	TotalBytes   int64              `json:"totalBytes"`
	RemovedBytes int64              `json:"removedBytes"`
	Removed      int                `json:"removed"`
	// Skipped counts entries a collection left in place because they were in use: a usage lease or build lock
	// held, or a file the file system reported busy. A skipped entry is not an error; the next collection retries it.
	Skipped        int      `json:"skipped,omitempty"`
	ProtectedBytes int64    `json:"protectedBytes"`
	LimitSatisfied bool     `json:"limitSatisfied"`
	Errors         []string `json:"errors,omitempty"`
}

func InspectCache

func InspectCache(options CacheLifecycleOptions) (CacheReport, error)

func PruneCaches

func PruneCaches(options CacheLifecycleOptions) (CacheReport, error)

type Drift

type Drift struct {
	// Rule is the rule that covers the change.
	Rule string `json:"rule"`
	// Symbol is the SDK symbol, Old and New its shapes, and Since the SDK release that changed it.
	Symbol string `json:"symbol"`
	Old    string `json:"old"`
	New    string `json:"new"`
	Since  string `json:"since"`
	// Rewrites reports whether pig upgrades this use mechanically.
	Rewrites bool `json:"rewrites"`
	// File and Line are the first use. Count is the number of uses seen.
	File  string `json:"file"`
	Line  int    `json:"line"`
	Count int    `json:"count"`
}

Drift is one SDK change an extension was written for the old shape of. It is what a failed Go build records (BuildFailure.Drift) and what `pig extension upgrade` and the startup prompt read.

type DriftClassifier

type DriftClassifier func(output []byte, source func(path string) ([]byte, error)) (drifts []Drift, diagnostics int)

DriftClassifier reads the compiler output of a failed Go build and returns the SDK changes its diagnostics name and how many diagnostics the output holds. source reads a file a diagnostic names.

type EntryIdentity

type EntryIdentity struct {
	InputDigest string
	Artifact    string
	Language    string
}

EntryIdentity is the publication identity a caller expects of a cache entry: the input digest that names it, its canonical artifact filename, and the language that built it.

type GoBuildModule

type GoBuildModule struct {
	// Dir holds go.mod, go.sum and the generated runner.
	Dir string
	// Command is the go command and Env its environment, which pins the module graph to the generated one.
	Command string
	Env     []string
	// SDKRoot is the SDK the build resolves.
	SDKRoot string
}

GoBuildModule is the generated module a build of one Go extension compiles, and the go command that compiles it. A tool reads the extension's types in it exactly as the build sees them: the same SDK, requirements and replaces.

type GoExtension

type GoExtension struct {
	Name             string
	Root             string
	ModulePath       string
	Package          string
	Factory          string
	Hash             string
	WorkspaceModules []string
	// Verify, when set, reports an error when the extension's source no longer matches Hash. A caller that derived Hash from the
	// source files sets it, so that a build proves the compiler read the source that was hashed (see cellInputsUnchanged).
	Verify func() error
}

GoExtension describes one factory-style Go SDK extension that can be packed into a generated subprocess runner. The extension package must expose a factory function with signature:

func Extension() *sdk.Extension

or the Factory name supplied here.

type GoPackedCell

type GoPackedCell struct {
	Key           string
	Hash          string
	CacheDir      string
	BinaryPath    string
	Cached        bool
	BuildDuration time.Duration
	Extensions    []GoExtension
	// Generation is this spawn attempt's packed-cell generation number
	// (pig additive, CNC-002), claimed by the caller before any build work so
	// an async crash report for a process this attempt is replacing cannot
	// mistake itself for still current. Zero (the default, for callers that
	// never claim one) makes the host claim the generation at spawn.
	Generation int
}

GoPackedCell describes a generated runner artifact. Packing is an execution optimization only: the generated binary is still a subprocess and each contained extension uses its own host socket.

func BuildGoPackedCell

func BuildGoPackedCell(ctx context.Context, cacheRoot, key string, extensions []GoExtension) (*GoPackedCell, error)

BuildGoPackedCell generates and builds a Go runner that hosts multiple factory-style Go SDK extensions in one subprocess artifact. The artifact is cached by a deterministic cell hash derived from the extension hashes and factory/package metadata.

func BuildGoPackedCellWithSDKRoot

func BuildGoPackedCellWithSDKRoot(ctx context.Context, cacheRoot, key string, extensions []GoExtension, preferredSDKRoot string) (*GoPackedCell, error)

BuildGoPackedCellWithSDKRoot builds a packed cell using preferredSDKRoot when the extensions do not declare their own valid SDK replacement. Hosts use this to keep packed builds on the running process's resolved config root.

type LispExtension

type LispExtension struct {
	Name    string
	Root    string
	Package string
	Factory string
	Hash    string
	// Verify, when set, reports an error once the source no longer hashes to Hash: a build runs it before it publishes.
	Verify func() error
}

LispExtension describes one factory-style Lisp extension that can be built into a generated runner image. The factory is the one function NEW-EXTENSION its ASDF system, or its single source file, defines; Package names the system or the file (without .lisp).

type LispPackedCell

type LispPackedCell struct {
	Key           string
	Hash          string
	CacheDir      string
	BinaryPath    string
	Cached        bool
	BuildDuration time.Duration
	Extensions    []LispExtension
}

LispPackedCell describes a generated Lisp runner image.

func BuildLispPackedCell

func BuildLispPackedCell(ctx context.Context, cacheRoot, key string, extensions []LispExtension) (*LispPackedCell, error)

BuildLispPackedCell builds, or reuses from the cache, the runner image that serves extensions: one SBCL image holding the SDK and every member's compiled factory. The host starts it like any packed runner, with one socket per member.

type PrebuiltExtension

type PrebuiltExtension struct {
	Name string
	Hash string
}

PrebuiltExtension identifies one extension inside a cell composition.

type PrebuiltRequest

type PrebuiltRequest struct {
	Language   string // "go" | "rust" | "python"
	Key        string // cell key (pack group)
	GOOS       string
	GOARCH     string
	Extensions []PrebuiltExtension
}

PrebuiltRequest describes the packed cell the host is about to build.

type PrebuiltResolver

type PrebuiltResolver interface {
	ResolvePrebuilt(PrebuiltRequest) (binaryPath string, ok bool)
}

PrebuiltResolver maps a cell composition to an already-built binary. The resolver owns the match policy (e.g. how strictly to compare pinned hashes); the host only supplies the composition it is about to build.

type PublishedEntry

type PublishedEntry struct {
	Dir          string
	ArtifactPath string
	Reused       bool // an existing valid entry satisfied the request without building
}

PublishedEntry is the result of resolving a content-addressed cache entry.

func PublishArtifact

func PublishArtifact(ctx context.Context, finalDir, canonicalName, inputDigest, language string, build func(scratch string) (artifactPath string, err error), keepAlso ...string) (PublishedEntry, error)

PublishArtifact deduplicates construction of a content-addressed cache entry across processes, for packed runtime cells and for compiled source-mode extension binaries alike. finalDir is the entry directory (named by inputDigest); canonicalName is the single published artifact's filename. build runs inside a private scratch directory and returns the finished primary artifact. The artifact can live in an external compiler cache; publication copies it into scratch before atomically renaming the complete entry.

Exactly one process builds a given finalDir: callers take a per-digest advisory lock (released automatically on process death, so a crash never wedges the cache), re-check the cache under the lock, then build into private scratch and publish with a single atomic rename. Readers therefore never observe a half-written entry, distinct Pig instances share one built artifact instead of each rebuilding it, and only {canonicalName, ready.json} is retained - compiler intermediates (generated source, Rust target/) are discarded.

func ReusePublishedArtifact

func ReusePublishedArtifact(finalDir string, want EntryIdentity) (PublishedEntry, bool)

ReusePublishedArtifact returns the complete entry at finalDir published for want, if one exists, and records its use. It never builds or waits for a lock. The check and the record happen under the entry's shared usage lock, which a collection holds exclusively while it renames an entry away: the entry is either reused and recorded before a collection can take the lock, or the collector has it and the entry is not reused.

type PythonExtension

type PythonExtension struct {
	Name    string
	Root    string
	Package string
	Factory string
	Hash    string
}

PythonExtension describes one factory-style Python SDK extension that can be packed into a generated subprocess runner. The module must expose a factory returning pig_sdk.Extension, typically:

def new_extension() -> pig_sdk.Extension

The generated runner is a Python subprocess and uses one socket per contained extension.

type PythonPackedCell

type PythonPackedCell struct {
	Key           string
	Hash          string
	CacheDir      string
	BinaryPath    string
	Cached        bool
	BuildDuration time.Duration
	Extensions    []PythonExtension
}

PythonPackedCell describes a generated Python packed-cell artifact.

func BuildPythonPackedCell

func BuildPythonPackedCell(ctx context.Context, cacheRoot, key string, extensions []PythonExtension) (*PythonPackedCell, error)

type RustExtension

type RustExtension struct {
	Name    string
	Root    string
	Package string
	Crate   string
	Factory string
	Hash    string
	// Verify, when set, reports an error when the extension's source no longer matches Hash. A caller that derived Hash from the
	// source files sets it, so that a build proves the compiler read the source that was hashed (see cellInputsUnchanged).
	Verify func() error
}

RustExtension describes one factory-style Rust SDK extension that can be packed into a generated subprocess runner. The crate must expose a factory function returning pig_sdk::Extension, typically:

pub fn new_extension() -> pig_sdk::Extension

The generated runner still runs as a subprocess and uses one socket per contained extension.

type RustPackedCell

type RustPackedCell struct {
	Key           string
	Hash          string
	CacheDir      string
	BinaryPath    string
	Cached        bool
	BuildDuration time.Duration
	Extensions    []RustExtension
}

RustPackedCell describes a generated Rust packed-cell artifact.

func BuildRustPackedCell

func BuildRustPackedCell(ctx context.Context, cacheRoot, key string, extensions []RustExtension) (*RustPackedCell, error)

BuildRustPackedCell generates and builds a Cargo runner that hosts multiple factory-style Rust SDK extensions in one subprocess artifact.

type UsageLease

type UsageLease struct {
	// contains filtered or unexported fields
}

func AcquireArtifactUsageLease

func AcquireArtifactUsageLease(artifactPath string) (*UsageLease, error)

AcquireArtifactUsageLease takes the shared usage lease on the cache entry that holds artifactPath, so a collection leaves the entry alone until the lease is released. A path outside the governed cache (a prebuilt binary, a source script) has no entry, and the lease is nil. An artifact that a cache entry held and that is gone is an error, not a nil lease: another pig's collection removed the entry after this process resolved it, and a nil lease would let the caller's spawn fail with a bare missing file while the use of the entry went untracked.

func AcquireUsageLease

func AcquireUsageLease(entryDir string) (*UsageLease, error)

func (*UsageLease) Release

func (l *UsageLease) Release() error

type UsageMetadata

type UsageMetadata struct {
	LastUsed int64 `json:"lastUsed"`
}

type VanishTracker

type VanishTracker struct {
	// contains filtered or unexported fields
}

VanishTracker decides, for a source hash walk, whether a directory that failed to open or list mid-walk was removed by another process and so held no source of the build. One tracker serves one walk: a directory it let the walk skip on weaker evidence is checked again by Verify once the walk ends.

A directory that is gone is vanished. Windows does not report a directory that another process is deleting as missing: it fails to open with ERROR_DELETE_PENDING, or with ERROR_ACCESS_DENIED, until the last handle on it closes. So:

  • not-exist, and ERROR_DELETE_PENDING, vanish the directory at once;
  • ERROR_ACCESS_DENIED vanishes it at once when a Lstat of the same directory finds it gone;
  • ERROR_ACCESS_DENIED followed by a Lstat that succeeds is a directory that is there and denies the walk: not vanished, so the hash fails;
  • ERROR_ACCESS_DENIED followed by a Lstat that is denied too is skipped provisionally and remembered. A delete-pending directory denies both calls, so the walk cannot tell it from a live one yet, and skipping it unchecked would let the sources of a live, unreadable tree drop out of the hash. Verify looks again once the walk is over: gone is fine; a Lstat that now succeeds means the directory exists, and the hash fails naming it; still denied is taken as delete-pending, because a directory that denies even its metadata to the user running the hash, and does not go away, is outside what a source hash can read either way.

func NewVanishTracker

func NewVanishTracker() *VanishTracker

NewVanishTracker returns a tracker that knows the deletion codes of the running OS.

func (*VanishTracker) Vanished

func (t *VanishTracker) Vanished(dir string, err error) bool

Vanished reports whether err, from opening or listing the directory dir of the local file system, means the walk may skip dir.

func (*VanishTracker) Verify

func (t *VanishTracker) Verify() error

Verify re-checks the directories Vanished skipped provisionally and returns an error naming the first that exists. Call it once, after the walk, and fail the hash on the error.

Jump to

Keyboard shortcuts

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