store

package
v2.0.0-beta.9 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store keeps snapshot blobs content-addressed under <state>/blobs/sha256/<digest>. Snapshot and instance directories hold hard links into it, so a part shared by two snapshots exists once on disk and pulling a snapshot that shares parts with one already present copies nothing. GC removes the blobs no snapshot refers to.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(ctx context.Context, src, dst string) (string, int64, error)

CopyFile creates dst (exclusively) from src, hashing the bytes as they pass and syncing the result.

func HashFile

func HashFile(ctx context.Context, name string) (string, int64, error)

HashFile is the SHA-256 and size of a file.

Types

type Store

type Store struct {
	Root string
}

Store is a blob directory.

func (Store) Add

func (s Store) Add(ctx context.Context, name string) (string, int64, error)

Add hashes the file and makes it a blob: a hard link when the file is on the store's filesystem, a copy otherwise. The blob, and through the link the file itself, becomes read-only.

func (Store) AddHashed

func (s Store) AddHashed(ctx context.Context, name, digest string) error

AddHashed records a file whose digest the caller already computed while writing it, without reading it again.

func (Store) BlobPath

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

BlobPath is where digest lives.

func (Store) Blobs

func (s Store) Blobs() string

Blobs is the blob directory.

func (Store) GC

func (s Store) GC(ctx context.Context, keep map[string]bool) (int64, error)

GC removes blobs not in keep and returns the bytes freed. A blob still linked from a snapshot directory keeps its data there; only the store's name goes.

func (Store) Has

func (s Store) Has(digest string) bool

Has reports whether the blob is present.

func (Store) Ingest

func (s Store) Ingest(ctx context.Context, r io.Reader, digest string, size int64) error

Ingest streams r into the store as digest, checking the bytes hash to it and number size. A blob already present is not read again.

func (s Store) Link(ctx context.Context, digest, dst string) error

Link materializes the blob at dst: a hard link, or a verified copy when dst is on another filesystem.

func (Store) List

func (s Store) List() ([]string, error)

List returns every blob digest.

Jump to

Keyboard shortcuts

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