planner

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package planner computes the desired file state for a profile apply or unapply. It reads the filesystem to check file existence and ownership but has no write side effects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conflict

type Conflict struct {
	ModFileVersionID int64
	ProfileItemID    int64
	Entry            RemappedEntry
	Priority         int64
	Won              bool
	// Display fields for dry-run output and status reporting.
	ModPageName   string
	FileLabel     string
	VersionString string // empty if not set
}

Conflict records a single mod's claim on a destination path.

type Plan

type Plan struct {
	GameInstallID int64
	ProfileID     int64 // 0 for unapply plans
	TargetID      int64
	TargetRoot    string
	Files         []PlanFile // one per destination path, apply plans only
	Ops           []PlanOp
	Warnings      []string

	// PatchBaseArchives is the set of archive sha256s that must be staged
	// for patch override base files, even if no mod write op requires them.
	PatchBaseArchives []string
}

Plan is the full computed desired state for a profile apply or unapply. It has no disk side effects and can be used directly for dry-run output.

func BuildApplyPlan

func BuildApplyPlan(ctx context.Context, q *dbq.Queries, gameInstallID, profileID int64, skipRecheck bool) (Plan, error)

BuildApplyPlan computes the desired file state for applying profileID to gameInstallID. It reads the filesystem to check file existence and ownership but does not modify anything.

func BuildUnapplyPlan

func BuildUnapplyPlan(ctx context.Context, q *dbq.Queries, gameInstallID int64) (Plan, error)

BuildUnapplyPlan computes the operations needed to remove all tool-managed files for a game install. It does not require the profile to still exist.

type PlanFile

type PlanFile struct {
	DestPath      string
	ProfileItemID int64
	Conflicts     []Conflict // sorted priority desc; exactly one has Won=true
}

PlanFile is the resolved state for a single destination path. The winner is the Conflict where Won == true. All other entries in Conflicts lost.

func (*PlanFile) Winner

func (pf *PlanFile) Winner() Conflict

Winner returns the winning Conflict for this path.

type PlanOp

type PlanOp struct {
	Kind     PlanOpKind
	DestPath string
	// File is set for Write, Overwrite ops.
	File *PlanFile
	// BackupSha256 is set for RestoreBackup ops.
	BackupSha256 string
	// NeedsBackup is true when a pre-existing non-tool-owned file must be
	// backed up before being overwritten.
	NeedsBackup bool

	// OverrideID is set when this op's content comes from an override.
	OverrideID sql.NullInt64
	// OverrideType is set when OverrideID is valid.
	// One of: "full_file", "ini_patch", "yaml_patch", "json_patch"
	OverrideType string
	// OverrideBlobSha256 is set for full_file override ops.
	OverrideBlobSha256 sql.NullString
	// OverrideBaseArchiveSha256 is set for patch override ops: the archive
	// that must be staged to provide the base file.
	OverrideBaseArchiveSha256 sql.NullString
	// OverrideBaseRawPath is the path inside the base archive for patch ops.
	OverrideBaseRawPath sql.NullString
}

PlanOp is a single file operation the apply step will execute.

type PlanOpKind

type PlanOpKind string

PlanOpKind describes what a single file operation will do.

const (
	PlanOpWrite         PlanOpKind = "write"
	PlanOpOverwrite     PlanOpKind = "overwrite"
	PlanOpRemove        PlanOpKind = "remove"
	PlanOpRestoreBackup PlanOpKind = "restore_backup"
	PlanOpNoop          PlanOpKind = "noop"
)

type RemappedEntry

type RemappedEntry struct {
	ArchiveSha256 string
	Position      int64
	SourcePath    string
	DestPath      string
	SizeBytes     int64
}

RemappedEntry is a single archive entry after remap rules have been applied.

type UninventoriedArchiveError

type UninventoriedArchiveError struct {
	ModFileVersionID int64
	ModPageName      string
	FileLabel        string
	ArchiveSha256    string
}

UninventoriedArchiveError is returned when a profile item references an archive that has not yet been scanned.

func (*UninventoriedArchiveError) Error

func (e *UninventoriedArchiveError) Error() string

Jump to

Keyboard shortcuts

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