internal

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DB_PRAGMAS = "?_foreign_keys=ON&_journal_mode=WAL&_synchronous=NORMAL"

Variables

View Source
var Migrations embed.FS

Functions

func AddRemapRule

func AddRemapRule(ctx context.Context, db *sql.DB, q *dbq.Queries, itemID int64, ruleType string, intVal sql.NullInt64, textVal sql.NullString, overridePos int64) error

AddRemapRule adds a single remap rule to the config for a profile item, creating the config if it does not exist yet. The position is auto-assigned as MAX(position)+1 unless overridePos is >= 0.

func ClearRemapConfig

func ClearRemapConfig(ctx context.Context, db *sql.DB, q *dbq.Queries, itemID int64, profileName string, versionID int64) error

ClearRemapConfig deletes all remap rules for a profile item's config and removes the config itself, leaving remap_config_id NULL on the profile item. No-op if the profile item has no remap config.

func CopyDeployRules added in v0.6.0

func CopyDeployRules(ctx context.Context, db *sql.DB, q *dbq.Queries, srcItemID, dstItemID int64, srcVersionID, dstVersionID int64, profileName string) error

CopyDeployRules copies skip-backup and write-once patterns from one profile item to another. If the destination already has patterns of either kind they are replaced. If the source has no patterns for a given kind that kind is a no-op. Returns the counts of patterns copied for each kind.

func CopyRemapConfig

func CopyRemapConfig(ctx context.Context, db *sql.DB, q *dbq.Queries, srcItemID, dstItemID int64, srcVersionID, dstVersionID int64, profileName string) error

CopyRemapConfig copies remap rules from one profile item to another within the same profile. If the destination already has a config its rules are replaced. If the source has no config this is a no-op.

func CopySkipBackupPatterns added in v0.6.0

func CopySkipBackupPatterns(ctx context.Context, db *sql.DB, q *dbq.Queries, srcItemID, dstItemID int64, srcVersionID, dstVersionID int64, profileName string) error

CopySkipBackupPatterns copies skip-backup patterns from one profile item to another within the same profile. If the destination already has patterns they are replaced. If the source has no patterns this is a no-op.

func CopyWriteOncePatterns added in v0.6.0

func CopyWriteOncePatterns(ctx context.Context, db *sql.DB, q *dbq.Queries, srcItemID, dstItemID int64, srcVersionID, dstVersionID int64, profileName string) error

CopyWriteOncePatterns copies write-once patterns from one profile item to another within the same profile. If the destination already has patterns they are replaced. If the source has no patterns this is a no-op.

func EnsureDBExists

func EnsureDBExists() error

EnsureDBExists verifies that the configured database file exists and is a regular file. If not, it returns a user-friendly error.

func EnsureRemapConfig

func EnsureRemapConfig(ctx context.Context, qtx *dbq.Queries, itemID int64) (int64, error)

EnsureRemapConfig returns the existing remap_config_id for a profile item, or creates a new one and links it to the profile item within the provided transaction if none exists yet.

func FullSelector

func FullSelector(storeID, storeGameID, instanceID string) string

FullSelector always includes the instance (even if it's "default").

Example: steam:1091500#default

func GooseProvider

func GooseProvider(db *sql.DB) (*goose.Provider, error)

func IsBinaryContent added in v0.6.0

func IsBinaryContent(data []byte) bool

IsBinaryContent reports whether data appears to be binary by scanning for null bytes in the first 8KB, matching the heuristic used by Git and other tools.

func IsUnderDir

func IsUnderDir(path, dir string) (bool, error)

isUnderDir reports whether the given path resides within the directory dir.

Both path and dir are first converted to absolute paths to avoid surprises with relative paths. The function then computes the relative path from dir to path using filepath.Rel.

If the resulting relative path starts with "..", the path lies outside dir. Otherwise, it is considered inside dir (including the case where path == dir).

This avoids unsafe string-prefix checks such as:

strings.HasPrefix(path, dir)

which can produce false positives (e.g. "/foo/bar-baz" vs "/foo/bar") and does not correctly handle ".." traversal.

The function does not resolve symlinks. If symlink-aware containment checks are required, both paths should be resolved via filepath.EvalSymlinks first.

func MigrateDB

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

func ParseInt64

func ParseInt64(s string) (int64, bool)

func ParseSelector

func ParseSelector(s string) (storeID, storeGameID, instanceID string, err error)

ParseSelector parses either: - store:game - store:game#instance

If instance is omitted, it returns instanceID="default".

func ResolveModFileVersionArg

func ResolveModFileVersionArg(ctx context.Context, q *dbq.Queries, gi dbq.GameInstall, arg string) (dbq.GetModFileVersionByIDRow, error)

ResolveModFileVersionArg resolves a mod file version argument for the given game install. Accepts:

  • a numeric ID (fast path, unambiguous)
  • a mod page name (case-insensitive; errors if ambiguous, listing all candidates with their numeric IDs)

func ResolveModPageArg

func ResolveModPageArg(ctx context.Context, q *dbq.Queries, gi dbq.GameInstall, arg string) (dbq.GetModPageByIDForGameRow, error)

ResolveModPageArg resolves a mod page argument for the given game install. Accepts:

  • a numeric ID (fast path, unambiguous)
  • a mod page name (case-insensitive; errors if ambiguous, listing all candidates with their numeric IDs)

func ResolveProfileItemByVersion

func ResolveProfileItemByVersion(ctx context.Context, profile *dbq.Profile, q *dbq.Queries, versionID int64) (int64, error)

ResolveProfileItemByVersion looks up a profile item by mod file version ID within a profile, returning a clean error if the version is not in the profile.

func RewriteProfilePriorities

func RewriteProfilePriorities(
	ctx context.Context,
	qtx *dbq.Queries,
	profileID int64,
	items []dbq.ListProfileItemsForOrderRow,
	start, step int64,
) error

RewriteProfilePriorities rewrites priorities for the given ordered items.

It is safe under UNIQUE(profile_id, priority) because it first shifts all existing priorities out of the way by an offset, then assigns final values.

start is the first priority value to assign (for compact: 1). step is the increment between consecutive priorities (for compact: 1; for --multiple N: N).

func SetProfileItemEnabled

func SetProfileItemEnabled(ctx context.Context, profile *dbq.Profile, q *dbq.Queries, versionID int64, enabled bool) error

func SetupDB

func SetupDB() (*sql.DB, error)

func SetupDBReadOnly

func SetupDBReadOnly() (*sql.DB, error)

func ShortSelector

func ShortSelector(storeID, storeGameID, instanceID string) string

ShortSelector includes the instance only if it isn't "default".

Example: steam:1091500 Example: steam:1091500#library_2

func WalkUpdateChain

func WalkUpdateChain(startFileID int64, next map[int64]int64) int64

WalkUpdateChain follows the file_updates chain from startFileID and returns the terminal (latest) file_id, or startFileID if no updates exist, using a prebuilt map of old_file_id -> new_file_id.

Types

type RefreshResult added in v0.2.0

type RefreshResult struct {
	New      []string // display names of newly discovered installs
	Updated  []string // display names of installs seen again (already present)
	Returned []string // display names of installs that were missing and came back
	Missing  []string // display names of installs that disappeared
	Skipped  []string // display names of installs that were filtered out
	Warnings []string
}

func ScanStores

func ScanStores(ctx context.Context, db *sql.DB, styles RefreshStyles) (RefreshResult, error)

type RefreshStyles added in v0.2.0

type RefreshStyles struct {
	Bold   lipgloss.Style
	Subtle lipgloss.Style
	Warn   lipgloss.Style
	Green  lipgloss.Style
	Red    lipgloss.Style
	Yellow lipgloss.Style
	Cyan   lipgloss.Style
}

type SqliteStore added in v0.2.0

type SqliteStore struct {
	database.Store // embed and delegate everything
}

A custom goose store to let us override the schema migrations table to use more idiomatic sqlite

func (*SqliteStore) CreateVersionTable added in v0.2.0

func (s *SqliteStore) CreateVersionTable(ctx context.Context, db database.DBTxConn) error

Directories

Path Synopsis
Package extractor handles extraction of mod archives to a staging directory and deployment of files into the game target directory.
Package extractor handles extraction of mod archives to a staging directory and deployment of files into the game target directory.
Package lock provides per-game-install exclusive locking for apply and unapply operations.
Package lock provides per-game-install exclusive locking for apply and unapply operations.
Package patchapply applies structured patch entries to ini, yaml, and json files.
Package patchapply applies structured patch entries to ini, yaml, and json files.
Package planner computes the desired file state for a profile apply or unapply.
Package planner computes the desired file state for a profile apply or unapply.
Package remap implements the remap rule engine for modctl.
Package remap implements the remap rule engine for modctl.

Jump to

Keyboard shortcuts

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