internal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: GPL-3.0 Imports: 21 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 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 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 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 ResolveGameInstallArg

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

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 ResolveProfileArg

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

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 ScanStores

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

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

This section is empty.

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 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