Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyWithContext ¶
CopyWithContext copies bytes from src to dst using the provided buffer, periodically checking ctx for cancellation.
It behaves similarly to io.CopyBuffer, but allows the caller to cancel long-running copy operations (e.g., very large archives) via context.
The function:
- Reads into the provided reusable buffer (no allocations inside the loop)
- Writes each chunk fully before proceeding
- Returns the total number of bytes successfully written
- Stops early if ctx is canceled
This is useful when ingesting large blobs where we want the CLI to remain interruptible (Ctrl+C, timeouts, etc.) without relying on OS-level signals to interrupt a blocking read.
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.