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 DriftResult ¶ added in v0.8.0
type DriftResult struct {
State DriftState
// Err is why the file could not be read, when State is DriftUnknown.
Err error
}
DriftResult is the outcome of CheckDrift.
func CheckDrift ¶ added in v0.8.0
func CheckDrift(ctx context.Context, absPath, installedSha string) (DriftResult, error)
CheckDrift hashes the file at absPath and compares it with installedSha, the content hash modctl recorded when it installed the file.
A file that isn't there is reported as DriftMissing. A file that is there but can't be read is reported as DriftUnknown and not as an error: what to do about not knowing is up to the caller. The one error is being told to stop (ctx is done), in which case the result is not meaningful, and the caller must not go on to overwrite a file that it didn't get to check.
type DriftState ¶ added in v0.8.0
type DriftState int
DriftState is how a file on disk compares with the content modctl recorded when it installed the file.
const ( // DriftNone means the file matches what modctl installed. DriftNone DriftState = iota // DriftMissing means there is no file at the path (any more), so there is // nothing that could have drifted. DriftMissing // DriftModified means the content of the file differs from what modctl // installed. DriftModified // DriftUnknown means the file could not be read, so there is no telling // whether it has changed. DriftUnknown )
type Plan ¶
type Plan struct {
GameInstallID int64
ProfileID int64 // 0 for unapply plans
TargetID int64
TargetName string
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, target dbq.Target, 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.
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.
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
// SkipBackup is true when a skip-backup pattern matched this path.
// Informational only; used for dry-run display.
SkipBackup bool
// WriteOnce is true when a write-once pattern matched this path.
// Informational only; used for dry-run display.
WriteOnce bool
}
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