db

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: GPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupReadOnly added in v0.3.2

func BackupReadOnly(ctx context.Context, sourcePath, destinationPath string) error

BackupReadOnly takes a consistent online SQLite backup without application bootstrap, migrations, journal-mode changes, or writes to the source DB. The destination must not exist and its parent must already be private.

func CookiePath

func CookiePath(dbPath, fileName string) (string, error)

CookiePath returns a path beneath the managed cookies subdirectory, creating that directory when needed.

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the preferred database path without creating it. When XDG_CONFIG_HOME is set, an existing canonical database wins, followed by an existing legacy .upbrr database under that same config root; otherwise a new canonical XDG path is returned. Without XDG_CONFIG_HOME, the user-home .upbrr path is returned.

func FileInSubdir

func FileInSubdir(dbPath, dirName, fileName string) (string, error)

FileInSubdir creates dirName beneath RootDir and returns fileName joined within it; it does not create the file.

func IsBusyError

func IsBusyError(err error) bool

IsBusyError reports whether err wraps a modernc SQLite BUSY or LOCKED result.

func Migrate

func Migrate(db *sql.DB) error

Migrate applies the registered migration graph using a background context.

func MigrateContext

func MigrateContext(ctx context.Context, db *sql.DB) error

MigrateContext validates and applies the registered forward-only migration graph in one BEGIN IMMEDIATE transaction. It bridges a recognized legacy user_version only when no migration IDs are recorded, then leaves the legacy compatibility version at 8 after all pending steps succeed.

func RootDir

func RootDir(dbPath string) (string, error)

RootDir returns and creates the parent directory used for database-adjacent files. Empty, in-memory, and SQLite URI inputs deliberately resolve to the default on-disk database directory instead of deriving a directory from the connection string.

func Subdir

func Subdir(dbPath, name string) (string, error)

Subdir creates name beneath RootDir and returns its path. Newly created directories use mode 0700.

Types

type DVDMediaInfo

type DVDMediaInfo = api.DVDMediaInfo

type DescriptionOverride

type DescriptionOverride = api.DescriptionOverride

type FileMetadata

type FileMetadata = api.FileMetadata

type HistoryEntry

type HistoryEntry = api.HistoryEntry

type HistoryRecord added in v0.3.0

type HistoryRecord = api.HistoryRecord

type IMDBMetadata

type IMDBMetadata = api.IMDBMetadata

type Identity added in v0.3.0

type Identity = api.ExternalIdentity

type Logger

type Logger interface {
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
}

Logger receives repository lifecycle, retry, and maintenance diagnostics. Repository operations do not require an error-level method because returned errors remain caller-owned.

type PlaylistInfo

type PlaylistInfo = api.PlaylistInfo

type PlaylistItem

type PlaylistItem = api.PlaylistItem

type PlaylistSelection

type PlaylistSelection = api.PlaylistSelection

type PreparedMediaBinding added in v0.3.2

type PreparedMediaBinding = api.PreparedMediaBinding

type ProviderMetadata added in v0.3.0

type ProviderMetadata = api.SourceScopedMetadata

type ReleaseNameOverrides

type ReleaseNameOverrides = api.ReleaseNameOverrides

type SQLiteRepository

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

SQLiteRepository owns one SQLite handle constrained to a single connection so connection-local PRAGMAs remain consistent. Callers must close the repository when finished; opening does not run schema migrations.

func Open

func Open(path string) (*SQLiteRepository, error)

Open opens path with a background context and no-op logger.

func OpenContext

func OpenContext(ctx context.Context, path string) (*SQLiteRepository, error)

OpenContext opens path with ctx and a no-op logger.

func OpenWithLogger

func OpenWithLogger(path string, logger Logger) (*SQLiteRepository, error)

OpenWithLogger opens path with a background context and logger.

func OpenWithLoggerContext

func OpenWithLoggerContext(ctx context.Context, path string, logger Logger) (*SQLiteRepository, error)

OpenWithLoggerContext resolves and opens path, enables foreign keys and a five-second busy timeout, and requires WAL mode for on-disk databases. In-memory databases retain their supported journal mode. A nil context is rejected and a nil logger is replaced with a no-op logger.

func (*SQLiteRepository) AcceptReleaseWorkflowIntent added in v0.3.0

func (r *SQLiteRepository) AcceptReleaseWorkflowIntent(
	ctx context.Context,
	record api.ReleaseWorkflowIntentRecord,
) (api.ReleaseWorkflowIntentRecord, bool, error)

AcceptReleaseWorkflowIntent atomically retains one exact Continue request.

func (*SQLiteRepository) AppendManualMenuScreenshots added in v0.2.4

func (r *SQLiteRepository) AppendManualMenuScreenshots(
	ctx context.Context,
	binding PreparedMediaBinding,
	screenshots []Screenshot,
	selections []ScreenshotFinalSelection,
) error

AppendManualMenuScreenshots atomically upserts manual menu screenshot records and appends their selections after existing manual-menu order values.

func (*SQLiteRepository) AppendReleaseWorkflowEvents added in v0.3.0

func (r *SQLiteRepository) AppendReleaseWorkflowEvents(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	events []api.WorkflowEvent,
) ([]api.WorkflowEvent, error)

AppendReleaseWorkflowEvents appends immutable events and assigns workflow-global sequences.

func (*SQLiteRepository) BeginReleaseWorkflowEffect added in v0.3.0

func (r *SQLiteRepository) BeginReleaseWorkflowEffect(
	ctx context.Context,
	record api.ReleaseWorkflowEffectRecord,
) (api.ReleaseWorkflowEffectRecord, bool, error)

BeginReleaseWorkflowEffect persists attempt_started before an external side effect.

func (*SQLiteRepository) CheckpointReleaseWorkflowWork added in v0.3.0

func (r *SQLiteRepository) CheckpointReleaseWorkflowWork(
	ctx context.Context,
	record api.ReleaseWorkflowWorkRecord,
) error

CheckpointReleaseWorkflowWork persists the latest safe operation state and renews its lease.

func (*SQLiteRepository) ClaimReleaseWorkflowWork added in v0.3.0

func (r *SQLiteRepository) ClaimReleaseWorkflowWork(
	ctx context.Context,
	record api.ReleaseWorkflowWorkRecord,
) error

ClaimReleaseWorkflowWork acquires one operation lease before worker dispatch.

func (*SQLiteRepository) Close

func (r *SQLiteRepository) Close() error

Close releases the owned SQLite handle. A nil or uninitialized repository is a no-op.

func (*SQLiteRepository) CommitPreparedRelease added in v0.3.0

func (r *SQLiteRepository) CommitPreparedRelease(ctx context.Context, release api.PreparedRelease) error

CommitPreparedRelease atomically replaces the current grouped release facts, canonical identity, and source-scoped provider metadata for one source.

func (*SQLiteRepository) CommitPreparedReleaseWithCorrections added in v0.3.2

func (r *SQLiteRepository) CommitPreparedReleaseWithCorrections(
	ctx context.Context,
	release api.PreparedRelease,
	expectedRevision uint64,
	record api.StoredReleaseCorrectionsV1,
	compatibility func(uint64) (api.PreparationCompatibility, error),
) (uint64, error)

CommitPreparedReleaseWithCorrections atomically compares and stores the correction record before publishing the prepared generation. Compatibility is computed from the authoritative revision within the transaction. The callback must perform only local computation; an error rolls back the complete commit.

func (*SQLiteRepository) CompareAndSwapReleaseCorrections added in v0.3.2

func (r *SQLiteRepository) CompareAndSwapReleaseCorrections(
	ctx context.Context,
	path string,
	expected uint64,
	record api.StoredReleaseCorrectionsV1,
) (api.ReleaseCorrectionsSnapshot, error)

CompareAndSwapReleaseCorrections atomically replaces one known correction record. It is used to bind accepted content without re-running preparation.

func (*SQLiteRepository) CompleteReleaseWorkflowEffect added in v0.3.0

func (r *SQLiteRepository) CompleteReleaseWorkflowEffect(
	ctx context.Context,
	status api.WorkflowEffectStatus,
	record api.ReleaseWorkflowEffectRecord,
) error

CompleteReleaseWorkflowEffect persists a known terminal receipt.

func (*SQLiteRepository) CompleteReleaseWorkflowWork added in v0.3.0

func (r *SQLiteRepository) CompleteReleaseWorkflowWork(
	ctx context.Context,
	record api.ReleaseWorkflowWorkRecord,
) error

CompleteReleaseWorkflowWork stores the final checkpoint and releases the work lease.

func (*SQLiteRepository) ConfigSectionLastUpdated

func (r *SQLiteRepository) ConfigSectionLastUpdated(ctx context.Context, section string) (time.Time, error)

ConfigSectionLastUpdated returns the last update time for a config section.

func (*SQLiteRepository) CreateReleaseWorkflowOperation added in v0.3.0

func (r *SQLiteRepository) CreateReleaseWorkflowOperation(
	ctx context.Context,
	record api.ReleaseWorkflowOperationRecord,
) (api.ReleaseWorkflowOperationRecord, bool, error)

CreateReleaseWorkflowOperation persists queued state before work begins. An exact idempotent repeat returns the existing operation.

func (*SQLiteRepository) CreateReleaseWorkflowState added in v0.3.0

func (r *SQLiteRepository) CreateReleaseWorkflowState(
	ctx context.Context,
	record api.ReleaseWorkflowStateRecord,
) (api.ReleaseWorkflowStateRecord, bool, error)

CreateReleaseWorkflowState atomically creates one workflow or returns the existing state for a matching owner-scoped creation key.

func (*SQLiteRepository) CreateUploadRecord

func (r *SQLiteRepository) CreateUploadRecord(ctx context.Context, record UploadRecord) error

func (*SQLiteRepository) DBPath added in v0.2.0

func (r *SQLiteRepository) DBPath() string

DBPath returns the resolved on-disk database path when the repository was opened from a normal filesystem path. It returns empty for SQLite sentinel or URI inputs so callers do not invent helper-file locations for in-memory DBs or opaque SQLite connection strings.

func (*SQLiteRepository) DeleteDescriptionOverride

func (r *SQLiteRepository) DeleteDescriptionOverride(ctx context.Context, path string, groupKey string) error

func (*SQLiteRepository) DeleteDiscMenuScreenshot added in v0.2.4

func (r *SQLiteRepository) DeleteDiscMenuScreenshot(
	ctx context.Context,
	binding PreparedMediaBinding,
	imagePath string,
) (api.DiscMenuDeleteResult, error)

DeleteDiscMenuScreenshot atomically removes one manual or automatic menu selection and all local records tied to it. It rejects normal final selections and returns a complete snapshot suitable for compensation with SQLiteRepository.RestoreDiscMenuScreenshot. Remote assets are unchanged.

func (*SQLiteRepository) DeleteFinalSelection

func (r *SQLiteRepository) DeleteFinalSelection(ctx context.Context, binding PreparedMediaBinding, imagePath string) error

func (*SQLiteRepository) DeletePlaylistSelection

func (r *SQLiteRepository) DeletePlaylistSelection(ctx context.Context, sourcePath string) error

DeletePlaylistSelection is retained for SQLite maintenance and migration tests; current workflows persist explicit empty selections.

func (*SQLiteRepository) DeleteReleaseNameOverrides

func (r *SQLiteRepository) DeleteReleaseNameOverrides(ctx context.Context, path string) error

DeleteReleaseNameOverrides is retained for SQLite maintenance and migration tests; current workflows replace overrides instead of deleting them.

func (*SQLiteRepository) DeleteReleaseWorkflowState added in v0.3.0

func (r *SQLiteRepository) DeleteReleaseWorkflowState(ctx context.Context, ownerID string, workflowID api.WorkflowID) error

DeleteReleaseWorkflowState removes one owner-scoped workflow.

func (*SQLiteRepository) DeleteScreenshot

func (r *SQLiteRepository) DeleteScreenshot(ctx context.Context, binding PreparedMediaBinding, imagePath string) error

DeleteScreenshot atomically removes the screenshot record and every local uploaded-image record keyed by imagePath. Final selections are not removed.

func (*SQLiteRepository) DeleteTerminalReleaseWorkflowOperationsBefore added in v0.3.0

func (r *SQLiteRepository) DeleteTerminalReleaseWorkflowOperationsBefore(ctx context.Context, before time.Time) (int64, error)

DeleteTerminalReleaseWorkflowOperationsBefore removes bounded terminal progress history while retaining queued and running work.

func (*SQLiteRepository) DeleteTerminalReleaseWorkflowStatesBefore added in v0.3.0

func (r *SQLiteRepository) DeleteTerminalReleaseWorkflowStatesBefore(ctx context.Context, before time.Time) (int64, error)

DeleteTerminalReleaseWorkflowStatesBefore deletes bounded terminal audit rows. Draft, active, and blocked workflows are never retention candidates.

func (*SQLiteRepository) DeleteUploadedImage

func (r *SQLiteRepository) DeleteUploadedImage(
	ctx context.Context,
	binding PreparedMediaBinding,
	imagePath string,
	host string,
) error

DeleteUploadedImage deletes every usage-scope record matching path, imagePath, and host. Repeated deletion succeeds once no matching record remains so retained workflow cleanup can safely replay after restart.

func (*SQLiteRepository) GetByPath

func (r *SQLiteRepository) GetByPath(ctx context.Context, path string) (FileMetadata, error)

GetByPath loads release metadata for path. Malformed legacy list or timestamp fields are left at their zero values; a missing row returns internalerrors.ErrNotFound.

func (*SQLiteRepository) GetDVDMediaInfo

func (r *SQLiteRepository) GetDVDMediaInfo(ctx context.Context, path string) (DVDMediaInfo, error)

GetDVDMediaInfo reads the SQLite-only DVD diagnostic record. It is not part of the release-state capability because no production workflow reads it.

func (*SQLiteRepository) GetDescriptionOverride

func (r *SQLiteRepository) GetDescriptionOverride(ctx context.Context, path string, groupKey string) (DescriptionOverride, error)

func (*SQLiteRepository) GetExternalIdentity added in v0.3.0

func (r *SQLiteRepository) GetExternalIdentity(ctx context.Context, path string) (Identity, error)

func (*SQLiteRepository) GetExternalMetadata

func (r *SQLiteRepository) GetExternalMetadata(ctx context.Context, path string) (ProviderMetadata, error)

func (*SQLiteRepository) GetPlaylistSelection

func (r *SQLiteRepository) GetPlaylistSelection(ctx context.Context, sourcePath string) (PlaylistSelection, error)

func (*SQLiteRepository) GetReleaseNameOverrides

func (r *SQLiteRepository) GetReleaseNameOverrides(ctx context.Context, path string) (ReleaseNameOverrides, error)

func (*SQLiteRepository) GetTrackerTimestamp

func (r *SQLiteRepository) GetTrackerTimestamp(ctx context.Context, tracker string) (time.Time, error)

func (*SQLiteRepository) ListActiveReleaseWorkflowOperations added in v0.3.0

func (r *SQLiteRepository) ListActiveReleaseWorkflowOperations(ctx context.Context) ([]api.ReleaseWorkflowOperationRecord, error)

ListActiveReleaseWorkflowOperations returns queued/running operations for process-restart recovery.

func (*SQLiteRepository) ListDescriptionOverridesByPath

func (r *SQLiteRepository) ListDescriptionOverridesByPath(ctx context.Context, path string) ([]DescriptionOverride, error)

func (*SQLiteRepository) ListFinalSelections

func (r *SQLiteRepository) ListFinalSelections(ctx context.Context, binding PreparedMediaBinding) ([]ScreenshotFinalSelection, error)

func (*SQLiteRepository) ListHistoryEntries

func (r *SQLiteRepository) ListHistoryEntries(ctx context.Context) ([]HistoryEntry, error)

ListHistoryEntries returns non-placeholder release rows in descending metadata-update order, with each row's latest upload and separate advisory versus non-advisory rule counts.

func (*SQLiteRepository) ListPendingUploads

func (r *SQLiteRepository) ListPendingUploads(ctx context.Context) ([]UploadRecord, error)

ListPendingUploads is retained as a SQLite diagnostic query and intentionally excluded from the upload-ledger capability until a production caller exists.

func (*SQLiteRepository) ListScreenshotSlotsByPath

func (r *SQLiteRepository) ListScreenshotSlotsByPath(ctx context.Context, binding PreparedMediaBinding) ([]ScreenshotSlot, error)

func (*SQLiteRepository) ListScreenshotsByPath

func (r *SQLiteRepository) ListScreenshotsByPath(ctx context.Context, binding PreparedMediaBinding) ([]Screenshot, error)

func (*SQLiteRepository) ListStoredReleasePaths

func (r *SQLiteRepository) ListStoredReleasePaths(ctx context.Context) ([]string, error)

func (*SQLiteRepository) ListTrackerMetadataByPath

func (r *SQLiteRepository) ListTrackerMetadataByPath(ctx context.Context, path string) ([]TrackerMetadata, error)

func (*SQLiteRepository) ListTrackerRuleFailuresByPath

func (r *SQLiteRepository) ListTrackerRuleFailuresByPath(ctx context.Context, path string) ([]TrackerRuleFailure, error)

func (*SQLiteRepository) ListUploadHistoryByPath

func (r *SQLiteRepository) ListUploadHistoryByPath(ctx context.Context, sourcePath string) ([]UploadRecord, error)

func (*SQLiteRepository) ListUploadedImagesByPath

func (r *SQLiteRepository) ListUploadedImagesByPath(ctx context.Context, binding PreparedMediaBinding) ([]UploadedImageLink, error)

func (*SQLiteRepository) LoadConfigSection

func (r *SQLiteRepository) LoadConfigSection(ctx context.Context, section string, dest any) error

LoadConfigSection retrieves a single config section from the database.

func (*SQLiteRepository) LoadFullConfig

func (r *SQLiteRepository) LoadFullConfig(ctx context.Context, dest any) error

LoadFullConfig reconstructs the entire config from all sections. Each raw section is rejected if it contains duplicate JSON object names before the sections are joined, so malformed stored data cannot collapse duplicate keys during unmarshaling.

func (*SQLiteRepository) LoadHistoryCleanupSnapshot added in v0.3.0

func (r *SQLiteRepository) LoadHistoryCleanupSnapshot(ctx context.Context, sourcePath string) (api.HistoryCleanupSnapshot, error)

LoadHistoryCleanupSnapshot returns caller-owned local artifact paths and the optional metadata needed to derive the managed release directory.

func (*SQLiteRepository) LoadHistoryRecord added in v0.3.0

func (r *SQLiteRepository) LoadHistoryRecord(ctx context.Context, sourcePath string) (api.HistoryRecord, error)

LoadHistoryRecord assembles one complete persisted history record. Optional release records remain zero-valued when absent; collection ordering is inherited from the canonical SQLite queries.

func (*SQLiteRepository) LoadLatestReleaseWorkflowOperation added in v0.3.0

func (r *SQLiteRepository) LoadLatestReleaseWorkflowOperation(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
) (api.ReleaseWorkflowOperationRecord, error)

LoadLatestReleaseWorkflowOperation returns the most recently updated operation for one owner-scoped workflow.

func (*SQLiteRepository) LoadMediaAssetSnapshot added in v0.3.0

func (r *SQLiteRepository) LoadMediaAssetSnapshot(ctx context.Context, binding api.PreparedMediaBinding) (api.MediaAssetSnapshot, error)

LoadMediaAssetSnapshot assembles the ordered media records for one release. Each query already returns caller-owned values; nested slot variants are cloned so callers cannot share mutable slice backing storage.

func (*SQLiteRepository) LoadPreparedRelease added in v0.3.0

func (r *SQLiteRepository) LoadPreparedRelease(ctx context.Context, sourcePath string) (api.PreparedRelease, error)

LoadPreparedRelease returns the current complete generation for sourcePath. Missing identity/metadata makes an incomplete derived generation a cache miss so canonical preparation can atomically replace it. Generation mismatches remain corrupt state and fail closed.

func (*SQLiteRepository) LoadReleaseCorrections added in v0.3.2

func (r *SQLiteRepository) LoadReleaseCorrections(ctx context.Context, path string) (api.ReleaseCorrectionsSnapshot, error)

LoadReleaseCorrections returns the saved correction record for path. A missing row behaves as an empty v1 record at revision zero.

func (*SQLiteRepository) LoadReleaseWorkflowEvents added in v0.3.0

func (r *SQLiteRepository) LoadReleaseWorkflowEvents(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	after uint64,
	limit int,
) ([]api.WorkflowEvent, error)

LoadReleaseWorkflowEvents returns immutable events after one workflow cursor.

func (*SQLiteRepository) LoadReleaseWorkflowOperation added in v0.3.0

func (r *SQLiteRepository) LoadReleaseWorkflowOperation(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
) (api.ReleaseWorkflowOperationRecord, error)

LoadReleaseWorkflowOperation returns one exact owner-scoped operation.

func (*SQLiteRepository) LoadReleaseWorkflowOperationByIdempotency added in v0.3.0

func (r *SQLiteRepository) LoadReleaseWorkflowOperationByIdempotency(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	commandName string,
	idempotencyKey string,
) (api.ReleaseWorkflowOperationRecord, error)

LoadReleaseWorkflowOperationByIdempotency returns one exact command receipt.

func (*SQLiteRepository) LoadReleaseWorkflowState added in v0.3.0

func (r *SQLiteRepository) LoadReleaseWorkflowState(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
) (api.ReleaseWorkflowStateRecord, error)

LoadReleaseWorkflowState returns one exact owner-scoped workflow row.

func (*SQLiteRepository) LoadReleaseWorkflowWork added in v0.3.0

func (r *SQLiteRepository) LoadReleaseWorkflowWork(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
) (api.ReleaseWorkflowWorkRecord, error)

LoadReleaseWorkflowWork returns one exact owner-scoped work lease and checkpoint.

func (*SQLiteRepository) MarkReleaseWorkflowOperationEffectsUnknown added in v0.3.0

func (r *SQLiteRepository) MarkReleaseWorkflowOperationEffectsUnknown(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	operationID api.WorkflowOperationID,
	now time.Time,
) error

MarkReleaseWorkflowOperationEffectsUnknown fences attempts interrupted by restart.

func (*SQLiteRepository) Migrate

func (r *SQLiteRepository) Migrate() error

Migrate applies pending repository migrations using a background context and the busy-lock retry policy.

func (*SQLiteRepository) MigrateContext

func (r *SQLiteRepository) MigrateContext(ctx context.Context) error

MigrateContext applies pending repository migrations under ctx and retries the complete migration operation for transient SQLite busy or locked errors.

func (*SQLiteRepository) PruneLiveTestState added in v0.3.2

func (r *SQLiteRepository) PruneLiveTestState(ctx context.Context) error

PruneLiveTestState transactionally clears every known production authority domain while preserving configuration and encrypted tracker authentication.

func (*SQLiteRepository) PurgeContentData

func (r *SQLiteRepository) PurgeContentData(ctx context.Context, path string) error

PurgeContentData atomically deletes persisted release, metadata, upload, and media rows for path, including matching retired UI-state rows. It does not remove local files or remote uploads.

func (*SQLiteRepository) PurgePreparedRelease added in v0.3.0

func (r *SQLiteRepository) PurgePreparedRelease(ctx context.Context, sourcePath string) error

PurgePreparedRelease deletes current prepared facts, canonical identity, and source-scoped provider metadata for one source in one transaction.

func (*SQLiteRepository) RawDB

func (r *SQLiteRepository) RawDB() *sql.DB

RawDB returns the underlying *sql.DB handle.

Callers using RawDB bypass repository safeguards such as validation, busy-retry behavior, and repository-level error wrapping. Restrict usage to approved low-level paths (for example migrations, tests, or advanced operations that are not exposed through repository methods), and avoid casual direct query/exec calls in application code.

func (*SQLiteRepository) RenewReleaseWorkflowWork added in v0.3.0

func (r *SQLiteRepository) RenewReleaseWorkflowWork(
	ctx context.Context,
	record api.ReleaseWorkflowWorkRecord,
) error

RenewReleaseWorkflowWork extends one currently owned work lease.

func (*SQLiteRepository) ReplaceDVDMenuScreenshots added in v0.2.4

func (r *SQLiteRepository) ReplaceDVDMenuScreenshots(
	ctx context.Context,
	binding PreparedMediaBinding,
	screenshots []Screenshot,
	selections []ScreenshotFinalSelection,
) ([]string, error)

ReplaceDVDMenuScreenshots atomically replaces automatic DVD-menu records and selections while preserving manual menus and normal screenshots. It returns replaced local image paths for caller-owned filesystem cleanup.

func (*SQLiteRepository) ReplaceNormalFinalSelections added in v0.2.4

func (r *SQLiteRepository) ReplaceNormalFinalSelections(
	ctx context.Context,
	binding PreparedMediaBinding,
	selections []ScreenshotFinalSelection,
) error

ReplaceNormalFinalSelections atomically replaces non-menu final selections for one exact binding while preserving its disc-menu selections.

func (*SQLiteRepository) ReplaceScreenshotSlots

func (r *SQLiteRepository) ReplaceScreenshotSlots(ctx context.Context, binding PreparedMediaBinding, slots []ScreenshotSlot) error

ReplaceScreenshotSlots atomically replaces all slots and variants for one exact binding; variants absent from slots are deleted.

func (*SQLiteRepository) RepositoryCapabilities added in v0.3.0

func (r *SQLiteRepository) RepositoryCapabilities() api.RepositoryCapabilities

RepositoryCapabilities returns immutable borrowed capability views over this SQLite owner. Every view shares its connection, transaction runner, retry policy, migration state, and lifecycle.

func (*SQLiteRepository) ResolveReleaseWorkflowEffectUnknown added in v0.3.0

func (r *SQLiteRepository) ResolveReleaseWorkflowEffectUnknown(
	ctx context.Context,
	ownerID string,
	workflowID api.WorkflowID,
	kind api.WorkflowExternalEffectKind,
	scopeID string,
	now time.Time,
) error

ResolveReleaseWorkflowEffectUnknown records manual verification that the latest uncertain effect did not complete, allowing a fresh exact attempt.

func (*SQLiteRepository) RestoreDiscMenuScreenshot added in v0.2.4

func (r *SQLiteRepository) RestoreDiscMenuScreenshot(
	ctx context.Context,
	binding PreparedMediaBinding,
	deleted api.DiscMenuDeleteResult,
) error

RestoreDiscMenuScreenshot atomically compensates a completed local-record deletion when the corresponding filesystem deletion could not be finalized. It rejects snapshots whose exact binding, image, menu purpose, or host data do not match the deleted selection.

func (*SQLiteRepository) Save

func (r *SQLiteRepository) Save(ctx context.Context, metadata FileMetadata) error

Save upserts release metadata by path, canonicalizing invalid categories to unknown and assigning the current UTC time when UpdatedAt is zero.

func (*SQLiteRepository) SaveConfigSection

func (r *SQLiteRepository) SaveConfigSection(ctx context.Context, section string, data any) error

SaveConfigSection persists a single config section as JSON.

func (*SQLiteRepository) SaveConfigSections added in v0.2.0

func (r *SQLiteRepository) SaveConfigSections(ctx context.Context, sections map[string]any) error

SaveConfigSections persists multiple prepared config sections in one transaction. The map keys are config root section names and values are marshaled before the transaction starts; if any section write fails, no selected section is committed.

func (*SQLiteRepository) SaveDVDMediaInfo

func (r *SQLiteRepository) SaveDVDMediaInfo(ctx context.Context, info DVDMediaInfo) error

func (*SQLiteRepository) SaveDescriptionOverride

func (r *SQLiteRepository) SaveDescriptionOverride(ctx context.Context, override DescriptionOverride) error

func (*SQLiteRepository) SaveExternalIdentity added in v0.3.0

func (r *SQLiteRepository) SaveExternalIdentity(ctx context.Context, ids Identity) error

func (*SQLiteRepository) SaveExternalMetadata

func (r *SQLiteRepository) SaveExternalMetadata(ctx context.Context, metadata ProviderMetadata) error

func (*SQLiteRepository) SaveFinalSelections

func (r *SQLiteRepository) SaveFinalSelections(ctx context.Context, binding PreparedMediaBinding, selections []ScreenshotFinalSelection) error

SaveFinalSelections atomically replaces every final selection for one exact prepared-media binding. Callers that must preserve menu selections should use SQLiteRepository.ReplaceNormalFinalSelections.

func (*SQLiteRepository) SaveFullConfig

func (r *SQLiteRepository) SaveFullConfig(ctx context.Context, cfg any) error

SaveFullConfig persists the entire config to all sections. This is called when exporting to database from YAML or UI updates.

func (*SQLiteRepository) SaveFullConfigWithPreSave added in v0.2.0

func (r *SQLiteRepository) SaveFullConfigWithPreSave(ctx context.Context, cfg any, preSave func(context.Context, *sql.Tx) error) error

SaveFullConfigWithPreSave persists the entire config and runs preSave in the same write transaction immediately before config sections are written. If preSave or any section write fails, the transaction is rolled back.

func (*SQLiteRepository) SavePlaylistSelection

func (r *SQLiteRepository) SavePlaylistSelection(
	ctx context.Context,
	sourcePath string,
	sourceFingerprint string,
	playlists []string,
	useAll bool,
) error

func (*SQLiteRepository) SaveReleaseNameOverrides

func (r *SQLiteRepository) SaveReleaseNameOverrides(ctx context.Context, path string, overrides ReleaseNameOverrides) error

func (*SQLiteRepository) SaveReleaseWorkflowContinuation added in v0.3.0

func (r *SQLiteRepository) SaveReleaseWorkflowContinuation(
	ctx context.Context,
	record api.ReleaseWorkflowContinuationRecord,
) error

SaveReleaseWorkflowContinuation materializes the latest safe continuation projection.

func (*SQLiteRepository) SaveReleaseWorkflowOperation added in v0.3.0

func (r *SQLiteRepository) SaveReleaseWorkflowOperation(
	ctx context.Context,
	expectedSequence uint64,
	record api.ReleaseWorkflowOperationRecord,
) error

SaveReleaseWorkflowOperation applies one optimistic sequence update without changing the workflow aggregate revision.

func (*SQLiteRepository) SaveReleaseWorkflowState added in v0.3.0

func (r *SQLiteRepository) SaveReleaseWorkflowState(
	ctx context.Context,
	expected api.WorkflowRevision,
	record api.ReleaseWorkflowStateRecord,
) error

SaveReleaseWorkflowState applies one optimistic revision update.

func (*SQLiteRepository) SaveScreenshot

func (r *SQLiteRepository) SaveScreenshot(ctx context.Context, binding PreparedMediaBinding, screenshot Screenshot) error

func (*SQLiteRepository) SaveTrackerMetadata

func (r *SQLiteRepository) SaveTrackerMetadata(ctx context.Context, metadata TrackerMetadata) error

func (*SQLiteRepository) SaveTrackerRuleFailures

func (r *SQLiteRepository) SaveTrackerRuleFailures(ctx context.Context, sourcePath string, tracker string, failures []TrackerRuleFailure) error

SaveTrackerRuleFailures atomically replaces one source/tracker result set. Tracker names are stored uppercase, blank rule names are skipped, missing timestamps default to now, and dispositions are normalized before storage.

func (*SQLiteRepository) SaveTrackerTimestamp

func (r *SQLiteRepository) SaveTrackerTimestamp(ctx context.Context, timestamp TrackerTimestamp) error

func (*SQLiteRepository) SaveUploadedImages

func (r *SQLiteRepository) SaveUploadedImages(
	ctx context.Context,
	binding PreparedMediaBinding,
	host string,
	images []UploadedImageLink,
) error

SaveUploadedImages upserts upload records without deleting omitted images. binding and host override their per-image fields; empty usage scopes default to "global" and zero upload times default to the current UTC time.

func (*SQLiteRepository) UpdateLatestUploadRecordStatus

func (r *SQLiteRepository) UpdateLatestUploadRecordStatus(ctx context.Context, sourcePath string, tracker string, status string) error

func (*SQLiteRepository) UpdateReleaseCorrections added in v0.3.2

func (r *SQLiteRepository) UpdateReleaseCorrections(
	ctx context.Context,
	path string,
	update api.ReleaseCorrectionUpdate,
) (api.ReleaseCorrectionsSnapshot, error)

UpdateReleaseCorrections applies one explicit correction operation within a short write transaction. It does not perform any remote work.

func (*SQLiteRepository) UpsertScreenshotSlotVariants

func (r *SQLiteRepository) UpsertScreenshotSlotVariants(
	ctx context.Context,
	binding PreparedMediaBinding,
	variants []ScreenshotSlotVariant,
) error

func (*SQLiteRepository) ValidateLiveTestSchema added in v0.3.2

func (r *SQLiteRepository) ValidateLiveTestSchema(ctx context.Context) error

ValidateLiveTestSchema accepts current and audited historical discard-only migrations, rejecting unknown migrations and unknown populated state. Run it before clone migrations as well as in the pruning transaction.

type Screenshot

type Screenshot = api.Screenshot

type ScreenshotFinalSelection

type ScreenshotFinalSelection = api.ScreenshotFinalSelection

type ScreenshotPurpose

type ScreenshotPurpose = api.ScreenshotPurpose

type ScreenshotSlot

type ScreenshotSlot = api.ScreenshotSlot

type ScreenshotSlotVariant

type ScreenshotSlotVariant = api.ScreenshotSlotVariant

type TMDBMetadata

type TMDBMetadata = api.TMDBMetadata

type TVDBMetadata

type TVDBMetadata = api.TVDBMetadata

type TVmazeMetadata

type TVmazeMetadata = api.TVmazeMetadata

type TrackerMetadata

type TrackerMetadata = api.TrackerMetadata

type TrackerRuleFailure

type TrackerRuleFailure = api.TrackerRuleFailure

type TrackerTimestamp

type TrackerTimestamp = api.TrackerTimestamp

type UploadRecord

type UploadRecord = api.UploadRecord
type UploadedImageLink = api.UploadedImageLink

Directories

Path Synopsis
Package dbfixture provides SQLite fixtures for integration tests outside the db package.
Package dbfixture provides SQLite fixtures for integration tests outside the db package.

Jump to

Keyboard shortcuts

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