blob

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package blob is a small content-addressed storage layer for flate's fetched artifacts. Blobs are indexed by sha256 digest; two artifacts with identical content share the same on-disk slot regardless of which CR resolved them. The store is the substrate the cache rework builds on — see pkg/source for ref-keyed slots that compose with this CAS via separate ref tables.

Layout under root:

<root>/blobs/sha256/<hex>/

Each blob is a directory so individual files (chart.tgz, README, etc.) can sit inside it without escaping the digest namespace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithSweepLock

func WithSweepLock(fn func() error) error

WithSweepLock acquires the exclusive sweep lock, calls fn, then releases the lock. Held across mark + sweep so no blob write can finalize within the window. The error returned by fn is propagated unchanged; the lock is always released.

Types

type Store

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

Store manages a content-addressed blob directory on disk. Safe for concurrent use; the keylock.KeyMap serializes Put for the same digest so two callers writing the same content don't race on rename finalize.

func NewStore

func NewStore(layout cacheroot.Layout) *Store

NewStore constructs a Store backed by the supplied Layout. The blob subtree is created lazily on first write; Layout's blob path methods are the single source of truth for on-disk positioning.

func (*Store) Exists

func (s *Store) Exists(digest string) bool

Exists reports whether a blob has been finalized for digest.

func (*Store) Path

func (s *Store) Path(digest string) string

Path returns the on-disk path for digest. Does not stat — callers use Exists to check populated-ness.

func (*Store) PutBytes

func (s *Store) PutBytes(ctx context.Context, content []byte, filename string) (string, string, error)

PutBytes installs content as a single file named filename inside the blob directory keyed by content's sha256. The digest is recomputed from the bytes (never trusted from caller input). Concurrent callers targeting the same digest serialize on a per-digest lock; the first finalizes via atomic rename and the rest observe ErrExists internally and return without rewriting. ctx cancellation aborts the lock acquire (no write performed).

Takes the package-level GC shared lock so a concurrent gc.Sweep can't age-read a stale mtime or delete the blob between this call's Exists check and its mtime refresh / finalize. The early-return path also refreshes the blob's mtime — without that bump, a reused-but-old blob would be age-pruned even though a live caller just touched it.

Returns the populated blob directory path and the computed digest.

Jump to

Keyboard shortcuts

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