types

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package types defines shared types and interfaces used across all doomsday packages. This package has zero internal dependencies — only Go stdlib.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRepoNotFound  = errors.New("repository not found")
	ErrRepoExists    = errors.New("repository already exists")
	ErrDecryptFailed = errors.New("decryption failed: wrong key or corrupted data")
	ErrLockConflict  = errors.New("repository is locked by another process")
	ErrCorrupted     = errors.New("data corruption detected")
	ErrNotFound      = errors.New("not found")
	ErrReadOnly      = errors.New("repository is read-only")
	ErrInvalidKey    = errors.New("invalid key or password")
	ErrVersionTooNew = errors.New("repository version is newer than this binary supports — please update doomsday")
	ErrRollback      = errors.New("repository rollback detected — snapshot(s) missing that were previously seen")
)

Sentinel errors used across packages.

Functions

func ValidateName

func ValidateName(name string) error

ValidateName checks that a backend file name is safe for use as a path component. Rejects names containing path separators, traversal sequences, or null bytes that could escape the repository directory.

Types

type Backend

type Backend interface {
	// Location returns a human-readable description of the backend.
	Location() string

	// Save writes data from rd to the backend under the given type and name.
	// The name should not include path separators — the backend maps FileType to directories.
	Save(ctx context.Context, t FileType, name string, rd io.Reader) error

	// Load reads a range of bytes from the named file.
	// If length is 0, the entire file is returned starting from offset.
	Load(ctx context.Context, t FileType, name string, offset, length int64) (io.ReadCloser, error)

	// Stat returns info about the named file.
	Stat(ctx context.Context, t FileType, name string) (FileInfo, error)

	// Remove deletes the named file.
	Remove(ctx context.Context, t FileType, name string) error

	// List calls fn for each file of the given type.
	// If fn returns an error, iteration stops and that error is returned.
	List(ctx context.Context, t FileType, fn func(FileInfo) error) error

	// Close releases any resources held by the backend.
	Close() error
}

Backend is the storage abstraction for repository data. Implementations exist for local filesystem, SFTP, and S3-compatible stores.

type BlobID

type BlobID [32]byte

BlobID is the HMAC-SHA256 content identifier for a blob (32 bytes).

func ParseBlobID

func ParseBlobID(s string) (BlobID, error)

ParseBlobID parses a hex-encoded blob ID string.

func (BlobID) IsZero

func (id BlobID) IsZero() bool

IsZero returns true if the blob ID is all zeros.

func (BlobID) Short

func (id BlobID) Short() string

Short returns the first 8 hex characters for display.

func (BlobID) String

func (id BlobID) String() string

String returns the hex-encoded blob ID.

type BlobType

type BlobType uint8

BlobType identifies the sub-category of a blob within a pack file.

const (
	BlobTypeData BlobType = iota // File content chunk
	BlobTypeTree                 // Directory listing
)

func (BlobType) String

func (bt BlobType) String() string

type FileInfo

type FileInfo struct {
	Name string
	Size int64
}

FileInfo describes a file in the backend.

type FileType

type FileType int

FileType identifies the category of a file within the repository layout.

const (
	FileTypePack     FileType = iota // data/ — pack files containing blobs
	FileTypeIndex                    // index/ — blob-to-pack mapping files
	FileTypeSnapshot                 // snapshots/ — snapshot metadata
	FileTypeKey                      // keys/ — key files
	FileTypeConfig                   // config — repository configuration
	FileTypeLock                     // locks/ — lock files
)

func (FileType) String

func (ft FileType) String() string

type PackedBlob

type PackedBlob struct {
	ID                 BlobID
	Type               BlobType
	PackID             string // name of the pack file
	Offset             uint32 // byte offset within the pack
	Length             uint32 // encrypted length in pack
	UncompressedLength uint32 // original size before compression (0 if uncompressed)
}

PackedBlob describes a blob stored within a pack file.

Jump to

Keyboard shortcuts

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