Help us shape the future of Go! Take the 2026 Go Developer Survey

blobstore

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureBlobRecorded

func EnsureBlobRecorded(
	ctx context.Context,
	q *dbq.Queries,
	sha256 string,
	kind string,
	sizeBytes int64,
	originalName *string,
) error

EnsureBlobRecorded ensures the blobs table has a row for sha256, enforcing invariants:

  • if the blob already exists, its kind and size must match
  • otherwise, insert it

verified_at is set only on insert. For existing blobs, verified_at is reserved for doctor --deep (rehash verification), not for "we saw a file".

Types

type BackupResult

type BackupResult struct {
	SHA256Hex string
	SizeBytes int64
	// Existed is true if the blob was already in the backup store (deduped)
	Existed bool
}

BackupResult is the outcome of a successful IngestBackup call

func IngestBackup

func IngestBackup(
	ctx context.Context,
	db *sql.DB,
	q *dbq.Queries,
	bs Store,
	srcPath string,
	gameInstallID int64,
	targetID int64,
	relpath string,
	operationID sql.NullInt64,
	originalContentSha256 string,
) (BackupResult, error)

IngestBackup copies srcPath into the backup blob store, records the blob, and upserts the backups row - all within a single transaction.

srcPath is the on-disk path of the pre-existing file to back up. originalContentSha256 is the hash of the file computed before ingestion, if already available; pass empty string if not.

type IngestResult

type IngestResult struct {
	SHA256Hex string
	SizeBytes int64
	Existed   bool
}

type Kind

type Kind string
const (
	KindArchive  Kind = "archive"
	KindBackup   Kind = "backup"
	KindOverride Kind = "override"
)

type Store

type Store struct {
	ArchivesDir  string
	BackupsDir   string
	OverridesDir string
	TmpDir       string
}

func (Store) IngestFile

func (s Store) IngestFile(ctx context.Context, kind Kind, srcPath string) (IngestResult, error)

IngestFile streams srcPath into the blob store, addressed by sha256. Writes a temp file in the destination directory and renames into place atomically.

func (Store) PathFor

func (s Store) PathFor(kind Kind, shaHex string) (string, error)

PathFor returns: <root>/ab/<fullhash>

func (Store) RootFor

func (s Store) RootFor(kind Kind) (string, error)

Jump to

Keyboard shortcuts

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