mediascanner

package
v2.18.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PhaseDiscovering     = "discovering"
	PhaseInitializing    = "initializing"
	PhaseCreatingIndexes = "creating_indexes"
	PhaseBuildingCaches  = "building_caches"
)

Variables

View Source
var ErrFsTimeout = errors.New("filesystem operation timed out")

ErrFsTimeout is returned when a filesystem operation exceeds the timeout.

Functions

func FindPath

func FindPath(ctx context.Context, 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 GetFiles

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

GetFiles searches for all valid games in a given path and returns a list of files. Uses fastwalk for parallel directory traversal with built-in symlink cycle detection. Deep searches .zip files when ZipsAsDirs is enabled.

func NewNamesIndex

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

func NewNamesIndexWithSources added in v2.18.0

func NewNamesIndexWithSources(
	ctx context.Context, platform platforms.Platform, cfg *config.Instance,
	systems []systemdefs.System, fdb *database.Database, update func(IndexStatus),
	pauser *syncutil.Pauser, sourceOptions *IndexSourceOptions,
) (indexedFiles int, err error)

NewNamesIndexWithSources reports selected successful launcher contributions without changing the existing filesystem or custom scanner contracts.

func SeedCanonicalTags added in v2.7.0

func SeedCanonicalTags(ctx context.Context, db database.MediaDBI) error

SeedCanonicalTags seeds the database with canonical GameDataBase-style hierarchical tag types and values (e.g. "genre:sports:wrestling", "players:2:vs"). Definitions live in the tags package. Runs set-based inside its own transaction; already-present rows are left untouched.

func StageMediaPath added in v2.16.0

func StageMediaPath(params *StageMediaPathParams) error

StageMediaPath parses one scanned file into its media fragments and appends them to the scanner staging tables. Tags, missing state, and most existence checks run set-based in ReconcileStagedSystem once the system's files are staged, so scanner memory does not grow with library or database size.

Types

type IndexSourceOptions added in v2.18.0

type IndexSourceOptions struct {
	Completed   func([]IndexedSource)
	LauncherIDs []string
}

IndexSourceOptions requests a bounded summary for selected launchers. Completed runs only after successful finalization; existing index callers need no hook.

type IndexStatus

type IndexStatus struct {
	SystemID string
	Phase    string // PhaseDiscovering, PhaseInitializing, or empty during indexing
	Total    int
	Step     int
	Files    int
}

type IndexedSource added in v2.18.0

type IndexedSource struct {
	LauncherID string
	SystemID   string
	Files      int
}

IndexedSource identifies an applicable contribution, not a durable media row.

type MediaPathFragments

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

func GetPathFragments

func GetPathFragments(params *PathFragmentParams) MediaPathFragments

type PathFragmentParams added in v2.7.0

type PathFragmentParams struct {
	Config              *config.Instance
	Path                string
	SystemID            string
	MediaType           slugs.MediaType
	ProvidedName        string
	PrefixPolicy        browseprefix.Policy
	NoExt               bool
	StripLeadingNumbers bool
}

PathFragmentParams contains parameters for GetPathFragments.

type PathResult

type PathResult struct {
	Path   string
	System systemdefs.System
}

func GetSystemPaths

func GetSystemPaths(
	ctx context.Context,
	cfg *config.Instance,
	platform platforms.Platform,
	rootFolders []string,
	systems []systemdefs.System,
) []PathResult

type StageMediaPathParams added in v2.16.0

type StageMediaPathParams struct {
	Config       *config.Instance
	Source       *platforms.MediaSource
	DB           database.MediaDBI
	Path         string
	SystemID     string
	MediaType    slugs.MediaType
	ProvidedName string
	PrefixPolicy browseprefix.Policy
	NoExt        bool
}

StageMediaPathParams contains parameters for StageMediaPath.

Jump to

Keyboard shortcuts

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