db

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
}

DB wraps the SQLite database connection

func New

func New(path string) (*DB, error)

New creates a new database connection and runs migrations

func (*DB) CheckFileConflicts added in v1.1.0

func (d *DB) CheckFileConflicts(gameID, profileName string, paths []string) (conflicts []FileConflict, err error)

CheckFileConflicts checks which of the given paths are already owned by other mods. Returns a slice of conflicts (empty if no conflicts).

func (*DB) DeleteDeployedFiles added in v1.1.0

func (d *DB) DeleteDeployedFiles(gameID, profileName, sourceID, modID string) error

DeleteDeployedFiles removes all deployed file records for a specific mod.

func (*DB) DeleteInstalledMod

func (d *DB) DeleteInstalledMod(sourceID, modID, gameID, profileName string) error

DeleteInstalledMod removes an installed mod record

func (*DB) DeleteToken

func (d *DB) DeleteToken(sourceID string) error

DeleteToken removes an API token for a source

func (*DB) GetDeployedFilesForMod added in v1.1.0

func (d *DB) GetDeployedFilesForMod(gameID, profileName, sourceID, modID string) (paths []string, err error)

GetDeployedFilesForMod returns all file paths deployed by a specific mod.

func (*DB) GetFileChecksum added in v1.1.0

func (d *DB) GetFileChecksum(sourceID, modID, gameID, profileName, fileID string) (string, error)

GetFileChecksum retrieves the checksum for a specific file Returns empty string if file not found or has no checksum

func (*DB) GetFileOwner added in v1.1.0

func (d *DB) GetFileOwner(gameID, profileName, relativePath string) (*FileOwner, error)

GetFileOwner returns the mod that owns a specific file path. Returns nil if no mod owns the file.

func (*DB) GetFilesWithChecksums added in v1.1.0

func (d *DB) GetFilesWithChecksums(gameID, profileName string) (files []FileWithChecksum, err error)

GetFilesWithChecksums returns all files for a game/profile with their checksums

func (*DB) GetInstalledMod

func (d *DB) GetInstalledMod(sourceID, modID, gameID, profileName string) (*domain.InstalledMod, error)

GetInstalledMod retrieves a single installed mod

func (*DB) GetInstalledMods

func (d *DB) GetInstalledMods(gameID, profileName string) (mods []domain.InstalledMod, err error)

GetInstalledMods returns all installed mods for a game/profile combination

func (*DB) GetModFileIDs added in v0.7.0

func (d *DB) GetModFileIDs(sourceID, modID, gameID, profileName string) (fileIDs []string, err error)

GetModFileIDs retrieves the file IDs for an installed mod

func (*DB) GetToken

func (d *DB) GetToken(sourceID string) (*StoredToken, error)

GetToken retrieves an API token for a source

func (*DB) HasToken

func (d *DB) HasToken(sourceID string) (bool, error)

HasToken checks if a token exists for a source

func (*DB) SaveDeployedFile added in v1.1.0

func (d *DB) SaveDeployedFile(gameID, profileName, relativePath, sourceID, modID string) error

SaveDeployedFile records that a file is deployed by a specific mod. Uses upsert to handle overwrites (new mod takes ownership).

func (*DB) SaveFileChecksum added in v1.1.0

func (d *DB) SaveFileChecksum(sourceID, modID, gameID, profileName, fileID, checksum string) error

SaveFileChecksum stores the MD5 checksum for a downloaded file

func (*DB) SaveInstalledMod

func (d *DB) SaveInstalledMod(mod *domain.InstalledMod) error

SaveInstalledMod inserts or updates an installed mod record

func (*DB) SaveToken

func (d *DB) SaveToken(sourceID, apiKey string) error

SaveToken saves or updates an API token for a source

func (*DB) SetModDeployed added in v1.1.0

func (d *DB) SetModDeployed(sourceID, modID, gameID, profileName string, deployed bool) error

SetModDeployed sets whether a mod is currently deployed to the game directory

func (*DB) SetModEnabled

func (d *DB) SetModEnabled(sourceID, modID, gameID, profileName string, enabled bool) error

SetModEnabled enables or disables a mod

func (*DB) SetModFileIDs added in v0.7.3

func (d *DB) SetModFileIDs(sourceID, modID, gameID, profileName string, fileIDs []string) error

SetModFileIDs updates the file IDs for an installed mod

func (*DB) SetModLinkMethod

func (d *DB) SetModLinkMethod(sourceID, modID, gameID, profileName string, linkMethod domain.LinkMethod) error

SetModLinkMethod updates the link method for an installed mod

func (*DB) SwapModVersions

func (d *DB) SwapModVersions(sourceID, modID, gameID, profileName string) error

SwapModVersions swaps version and previous_version (for rollback). Uses explicit read-then-write so the swap is correct regardless of SQL evaluation order.

func (*DB) UpdateModPolicy

func (d *DB) UpdateModPolicy(sourceID, modID, gameID, profileName string, policy domain.UpdatePolicy) error

UpdateModPolicy updates the update policy for an installed mod

func (*DB) UpdateModVersion

func (d *DB) UpdateModVersion(sourceID, modID, gameID, profileName, newVersion string) error

UpdateModVersion updates a mod's version, preserving the previous version for rollback

type FileConflict added in v1.1.0

type FileConflict struct {
	RelativePath string
	SourceID     string
	ModID        string
}

FileConflict represents a file that would be overwritten

type FileOwner added in v1.1.0

type FileOwner struct {
	SourceID string
	ModID    string
}

FileOwner represents the mod that owns a deployed file

type FileWithChecksum added in v1.1.0

type FileWithChecksum struct {
	SourceID string
	ModID    string
	FileID   string
	Checksum string
}

FileWithChecksum represents a file record with its checksum

type StoredToken

type StoredToken struct {
	SourceID  string
	APIKey    string
	UpdatedAt time.Time
}

StoredToken represents an API token stored in the database

Jump to

Keyboard shortcuts

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