Documentation
¶
Index ¶
- type DB
- func (d *DB) ApplyModUpdate(sourceID, modID, gameID, profileName, newVersion string, newFileIDs []string) error
- func (d *DB) CheckFileConflicts(gameID, profileName string, paths []string) (conflicts []FileConflict, err error)
- func (d *DB) DeleteDeployedFile(gameID, profileName, relativePath string) error
- func (d *DB) DeleteDeployedFiles(gameID, profileName, sourceID, modID string) error
- func (d *DB) DeleteInstalledMod(sourceID, modID, gameID, profileName string) error
- func (d *DB) DeleteToken(sourceID string) error
- func (d *DB) GetDeployedFilesForMod(gameID, profileName, sourceID, modID string) (paths []string, err error)
- func (d *DB) GetFileChecksum(sourceID, modID, gameID, profileName, fileID string) (string, error)
- func (d *DB) GetFileOwner(gameID, profileName, relativePath string) (*FileOwner, error)
- func (d *DB) GetFilesWithChecksums(gameID, profileName string) (files []FileWithChecksum, err error)
- func (d *DB) GetInstalledMod(sourceID, modID, gameID, profileName string) (*domain.InstalledMod, error)
- func (d *DB) GetInstalledMods(gameID, profileName string) (mods []domain.InstalledMod, err error)
- func (d *DB) GetLastDeployTime(gameID, profileName string) (*time.Time, error)
- func (d *DB) GetModFileIDs(sourceID, modID, gameID, profileName string) (fileIDs []string, err error)
- func (d *DB) GetToken(sourceID string) (*StoredToken, error)
- func (d *DB) HasToken(sourceID string) (bool, error)
- func (d *DB) ListTokens() ([]StoredToken, error)
- func (d *DB) SaveDeployedFile(gameID, profileName, relativePath, sourceID, modID string) error
- func (d *DB) SaveFileChecksum(sourceID, modID, gameID, profileName, fileID, checksum string) error
- func (d *DB) SaveInstalledMod(mod *domain.InstalledMod) error
- func (d *DB) SaveToken(sourceID, apiKey string) error
- func (d *DB) SetModConvertPaks(sourceID, modID, gameID, profileName string, convert bool) error
- func (d *DB) SetModDeployed(sourceID, modID, gameID, profileName string, deployed bool) error
- func (d *DB) SetModEnabled(sourceID, modID, gameID, profileName string, enabled bool) error
- func (d *DB) SetModFileIDs(sourceID, modID, gameID, profileName string, fileIDs []string) error
- func (d *DB) SetModLinkMethod(sourceID, modID, gameID, profileName string, linkMethod domain.LinkMethod) error
- func (d *DB) SetModVersion(sourceID, modID, gameID, profileName, version string) error
- func (d *DB) SwapModVersions(sourceID, modID, gameID, profileName string) error
- func (d *DB) UpdateModPolicy(sourceID, modID, gameID, profileName string, policy domain.UpdatePolicy) error
- func (d *DB) UpdateModVersion(sourceID, modID, gameID, profileName, newVersion string) error
- type FileConflict
- type FileOwner
- type FileWithChecksum
- type StoredToken
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB wraps the SQLite database connection
func (*DB) ApplyModUpdate ¶ added in v1.3.3
func (d *DB) ApplyModUpdate(sourceID, modID, gameID, profileName, newVersion string, newFileIDs []string) error
ApplyModUpdate updates version and file IDs atomically while preserving rollback state.
func (*DB) CheckFileConflicts ¶ added in v0.9.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) DeleteDeployedFile ¶ added in v1.29.0
DeleteDeployedFile removes one deployed-file ownership row. Deleting a row that does not exist is a silent no-op - convergence (#168/#212) calls this for paths it just undeployed, and a row may already be gone when the path was attributed only by a dangling link.
func (*DB) DeleteDeployedFiles ¶ added in v0.9.0
DeleteDeployedFiles removes all deployed file records for a specific mod.
func (*DB) DeleteInstalledMod ¶
DeleteInstalledMod removes an installed mod record
func (*DB) DeleteToken ¶
DeleteToken removes an API token for a source
func (*DB) GetDeployedFilesForMod ¶ added in v0.9.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 v0.8.0
GetFileChecksum retrieves the checksum for a specific file Returns empty string if file not found or has no checksum
func (*DB) GetFileOwner ¶ added in v0.9.0
GetFileOwner returns the mod that owns a specific file path. Returns nil if no mod owns the file.
func (*DB) GetFilesWithChecksums ¶ added in v0.8.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) GetLastDeployTime ¶ added in v1.18.0
GetLastDeployTime returns the most recent deployed_at recorded for gameID/profileName across every tracked file (#106a's dashboard "Last deploy" row), or nil if the profile has never had a file deployed. A never-deployed profile is a normal state, not an error.
Deliberately ORDER BY ... DESC LIMIT 1 rather than SELECT MAX(deployed_at): the modernc.org/sqlite driver converts a TEXT column to time.Time on Scan by consulting the column's DECLARED type (deployed_at is DATETIME, per migrateV7) - but MAX(deployed_at) is a computed expression with no declared type of its own, so the driver hands back the raw SQLite storage string instead and Scan(&time.Time) fails ("unsupported Scan ... string into type *time.Time"), verified empirically against this driver version. Selecting the actual column keeps the declared-type conversion intact and is equivalent to MAX for this query shape (both scoped to one game/profile, ORDER BY DESC LIMIT 1 is exactly "the row with the largest deployed_at").
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) ListTokens ¶ added in v1.8.0
func (d *DB) ListTokens() ([]StoredToken, error)
ListTokens returns every stored API token, ordered by source ID, regardless of whether that source is still registered. `lmm auth status` uses this to surface orphaned tokens (source removed or renamed) that would otherwise be invisible.
func (*DB) SaveDeployedFile ¶ added in v0.9.0
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 v0.8.0
SaveFileChecksum stores the MD5 checksum for a downloaded file. The target installed_mod_files row must already exist: an UPDATE matching no row would otherwise succeed as a silent no-op while the caller believes the checksum was persisted (#164), so 0 affected rows is an error.
func (*DB) SaveInstalledMod ¶
func (d *DB) SaveInstalledMod(mod *domain.InstalledMod) error
SaveInstalledMod inserts or updates an installed mod record. The mod upsert and file ID replacement are performed atomically within a transaction. On update of an existing record, the existing update_policy is preserved: callers always pass the default policy, so honoring it here would silently reset a user-set --pin/--auto policy on reinstall. Policy changes go through UpdateModPolicy. A first-time insert still uses the policy passed in. Similarly, convert_paks is never written here - the schema default covers first insert, and SetModConvertPaks is the only writer, so reinstall can't reset it.
func (*DB) SetModConvertPaks ¶ added in v1.30.0
SetModConvertPaks sets the per-mod pak-conversion flag (#221).
func (*DB) SetModDeployed ¶ added in v0.7.8
SetModDeployed sets whether a mod is currently deployed to the game directory
func (*DB) SetModEnabled ¶
SetModEnabled enables or disables a mod
func (*DB) SetModFileIDs ¶ added in v0.7.3
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) SetModVersion ¶ added in v1.23.0
SetModVersion corrects an installed mod's recorded version in place: a plain UPDATE of the version column only. Unlike UpdateModVersion, it does NOT shift the current version into previous_version/previous_file_ids - this is for repairing a WRONG recorded value (issue #94's verify --fix), not a real version change that should be rollback-able. And unlike SaveInstalledMod's full-row upsert, it does NOT touch installed_mod_files at all: SaveInstalledMod always runs replaceModFileIDsTx (DELETE + a checksum-less re-INSERT), so calling it just to fix the version string silently wipes every stored checksum for the mod's files even when the file IDs themselves never changed. SetModVersion exists specifically to avoid that: the version is wrong, the file IDs and their checksums are not, so only the version column should move.
func (*DB) SwapModVersions ¶
SwapModVersions swaps version and previous_version (for rollback). The read/write and file ID restoration are performed atomically within a transaction.
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 ¶
UpdateModVersion updates a mod's version, preserving the previous version and file IDs for rollback.
type FileConflict ¶ added in v0.9.0
FileConflict represents a file that would be overwritten
type FileWithChecksum ¶ added in v0.8.0
FileWithChecksum represents a file record with its checksum