mediascanner

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMediaPath

func AddMediaPath(
	db database.MediaDBI,
	ss *database.ScanState,
	systemID string,
	path string,
	noExt bool,
	stripLeadingNumbers bool,
	cfg *config.Instance,
) (titleIndex, mediaIndex int, err error)

func FindPath

func FindPath(path string) (string, error)

FindPath case-insensitively finds a file/folder at a path and returns the actual filesystem case. On case-insensitive filesystems (Windows, macOS), this ensures we get the real case from the filesystem rather than preserving the input case, which prevents case-mismatch issues during string comparisons.

This function recursively normalizes the entire path from root to leaf to ensure all components match the actual filesystem case.

Special handling:

  • Linux: Prefers exact match before case-insensitive match (handles File.txt vs file.txt)
  • Windows: Handles 8.3 short names (PROGRA~1) via fallback to os.Stat
  • All platforms: Works with symlinks, UNC paths, network drives

func FlushScanStateMaps

func FlushScanStateMaps(ss *database.ScanState)

FlushScanStateMaps clears the in-memory maps for titles and media to free memory between transaction commits during batch indexing.

IMPORTANT: SystemIDs, TagIDs, and TagTypeIDs are NOT cleared because:

  • They are global entities reused across all batches/systems
  • There are relatively few of them (~100-200 systems, ~40 tag types)
  • Clearing SystemIDs causes duplicate insert attempts with batch inserts enabled
  • Preserving them prevents UNIQUE constraint violations on subsequent inserts

func GetFiles

func GetFiles(
	ctx context.Context,
	cfg *config.Instance,
	platform platforms.Platform,
	systemID string,
	path string,
) ([]string, error)

GetFiles searches for all valid games in a given path and returns a list of files. This function deep searches .zip files and handles symlinks at all levels.

func NewNamesIndex

func NewNamesIndex(
	ctx context.Context,
	platform platforms.Platform,
	cfg *config.Instance,
	systems []systemdefs.System,
	fdb *database.Database,
	update func(IndexStatus),
) (int, error)

NewNamesIndex takes a list of systems, indexes all valid game files on disk and writes a name index to the DB.

Overwrites any existing names index but does not clean up old missing files.

Takes a function which will be called with the current status of the index during key steps.

Returns the total number of files indexed.

func PopulateScanStateForSelectiveIndexing added in v2.7.0

func PopulateScanStateForSelectiveIndexing(
	ctx context.Context, db database.MediaDBI, ss *database.ScanState, systemsToReindex []string,
) error

PopulateScanStateForSelectiveIndexing populates scan state for selective indexing with optimized loading. Uses true lazy loading for Systems/TagTypes (via UNIQUE constraints) and minimal data loading for MediaTitles/Media (only systems NOT being reindexed) to dramatically improve performance.

func PopulateScanStateFromDB added in v2.7.0

func PopulateScanStateFromDB(ctx context.Context, db database.MediaDBI, ss *database.ScanState) error

PopulateScanStateFromDB initializes the scan state with existing database IDs when resuming an interrupted indexing operation

func SeedCanonicalTags added in v2.7.0

func SeedCanonicalTags(db database.MediaDBI, ss *database.ScanState) error

SeedCanonicalTags seeds the database with canonical GameDataBase-style hierarchical tags. Tags follow the format: category:subcategory:value (e.g., "genre:sports:wrestling", "players:2:vs") Tag definitions are in tags.go for centralized management.

NOTE: This function ALWAYS uses non-batch mode (prepared statements) because the canonical tag dataset contains many entries and using batch mode with fail-fast behavior would cause issues. Prepared statements handle this better.

Types

type IndexStatus

type IndexStatus struct {
	SystemID string
	Total    int
	Step     int
	Files    int
}

type MediaPathFragments

type MediaPathFragments struct {
	Path     string
	FileName string
	Title    string
	Slug     string
	Ext      string
	Tags     []string
}

func GetPathFragments

func GetPathFragments(params PathFragmentParams) MediaPathFragments

type PathFragmentKey added in v2.7.0

type PathFragmentKey struct {
	Path                string
	FilenameTags        bool
	StripLeadingNumbers bool
}

type PathFragmentParams added in v2.7.0

type PathFragmentParams struct {
	Config              *config.Instance
	Path                string
	SystemID            string
	NoExt               bool
	StripLeadingNumbers bool
}

PathFragmentParams contains parameters for GetPathFragments.

type PathResult

type PathResult struct {
	Path   string
	System systemdefs.System
}

func GetSystemPaths

func GetSystemPaths(
	_ *config.Instance,
	_ platforms.Platform,
	rootFolders []string,
	systems []systemdefs.System,
) []PathResult

Jump to

Keyboard shortcuts

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