materialize

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package materialize owns the verified digest-keyed file store beneath a target deployment root and safe placement into out-of-place realizations.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCorrupt      = errors.New("materialize: stored file is corrupt")
	ErrSizeMismatch = errors.New("materialize: size mismatch")
	ErrDestination  = errors.New("materialize: destination already exists")
)

Functions

This section is empty.

Types

type PersistentKind

type PersistentKind string
const (
	PersistentFile      PersistentKind = "file"
	PersistentDirectory PersistentKind = "directory"
)

type Result

type Result struct {
	Path    string
	Bytes   int64
	Existed bool
}

type Store

type Store struct{ DeployRoot string }

func (Store) BindPersistent

func (s Store) BindPersistent(realizationDir, repositoryID, resourcePath, declared, realizationRelative string, kind PersistentKind) error

BindPersistent creates a target-scoped persistent directory and installs a relative symlink at an exact realization-relative path. Both paths are containment checked and a collision is refused.

func (Store) BindPersistentForPublication

func (s Store) BindPersistentForPublication(stagingDir, publishedDir, repositoryID, resourcePath, declared, realizationRelative string, kind PersistentKind) error

BindPersistentForPublication creates the symlink in stagingDir but computes its relative target from publishedDir. Atomic directory publication may change path depth, so a link made relative to staging itself would escape or point at the wrong shared root after rename.

func (Store) Path

func (s Store) Path(digest string) (string, error)

func (Store) PlaceImmutable

func (s Store) PlaceImmutable(digest string, size int64, realizationDir, relativePath string) error

PlaceImmutable verifies the store object then hard-links it into a new realization. It refuses every pre-existing destination.

func (Store) Put

func (s Store) Put(ctx context.Context, digest string, size int64, src io.Reader) (Result, error)

Put streams exactly size bytes into a same-directory temporary file, hashes while writing, fsyncs, makes it read-only, publishes without replacement, then fsyncs the parent directory. A concurrent winner is accepted only after its full bytes are verified.

func (Store) Verify

func (s Store) Verify(digest string, size int64) error

Verify reads the entire stored ordinary file. Existence or a matching file name is never accepted as proof of content identity.

Jump to

Keyboard shortcuts

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