blobs

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manifest

type Manifest struct {
	Version   int64          `json:"version"`
	CreatedAt int64          `json:"created_at"`
	RepoRoot  string         `json:"repo_root"`
	Files     []ManifestFile `json:"files"`
}

type ManifestFile

type ManifestFile struct {
	Path       string      `json:"path"`
	Blob       string      `json:"blob"`
	Size       int64       `json:"size"`
	Mode       os.FileMode `json:"mode"`
	ModTimeNs  int64       `json:"mod_time_ns,omitempty"`
	IsSymlink  bool        `json:"is_symlink,omitempty"`
	LinkTarget string      `json:"link_target,omitempty"`
}

type ManifestResult

type ManifestResult struct {
	Manifest     Manifest
	ManifestHash string
	TotalBytes   int64
}

ManifestResult holds the output of BuildManifest.

func BuildManifest

func BuildManifest(ctx context.Context, bs *Store, repoRoot string, paths []string, readFile func(rel string) ([]byte, error), prevFiles []ManifestFile) (*ManifestResult, error)

BuildManifest reads each file via readFile, stores blobs, builds a manifest, and stores the manifest blob itself. Returns the manifest hash and total size.

If prevFiles is non-nil, unchanged files (same path, size, mode, and mtime) reuse the previous blob hash without re-reading or re-hashing the file. Symlinks are always re-read regardless of previous state.

type Store

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

func NewStore

func NewStore(root string) (*Store, error)

func (*Store) Exists

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

Exists reports whether the compressed blob file already exists in this store.

func (*Store) Get

func (s *Store) Get(ctx context.Context, hash string) ([]byte, error)

func (*Store) Propagate

func (s *Store) Propagate(ctx context.Context, hash string, src *Store) error

Propagate transfers a blob by hash from src into this store. It attempts a hardlink first (zero-copy, same filesystem). If the hardlink fails for any reason other than the destination already existing, it falls back to a raw copy of the compressed file - no decompress/recompress cycle.

func (*Store) Put

func (s *Store) Put(ctx context.Context, b []byte) (hash string, size int64, err error)

Put stores bytes in a content-addressed path and returns the sha256 hex hash. Hash is computed on raw (uncompressed) bytes; bytes are stored compressed. It is idempotent: if the blob already exists, it does nothing.

func (*Store) StoredSize

func (s *Store) StoredSize(hash string) (int64, error)

StoredSize returns the on-disk compressed size for a blob in this store.

Jump to

Keyboard shortcuts

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