Documentation
¶
Overview ¶
Package extractor handles extraction of mod archives to a staging directory and deployment of files into the game target directory.
Index ¶
- func PruneDirs(targetRoot string, paths []string) []string
- type DeployFileResult
- type DeployOverrideFileResult
- type Extractor
- func (e Extractor) CleanupStaging(ctx context.Context) error
- func (e Extractor) ClearStaging(ctx context.Context) error
- func (e Extractor) DeployFile(ctx context.Context, db *sql.DB, q *dbq.Queries, op planner.PlanOp, ...) (DeployFileResult, error)
- func (e Extractor) DeployOverrideFile(ctx context.Context, db *sql.DB, q *dbq.Queries, op planner.PlanOp, ...) (DeployOverrideFileResult, error)
- func (e Extractor) ExtractArchive(ctx context.Context, archiveSha256 string) (string, error)
- func (e Extractor) RemoveFile(ctx context.Context, db *sql.DB, q *dbq.Queries, op planner.PlanOp, ...) (RemoveFileResult, error)
- func (e Extractor) RestoreFile(ctx context.Context, db *sql.DB, q *dbq.Queries, op planner.PlanOp, ...) (RestoreFileResult, error)
- func (e Extractor) StagingPathFor(archiveSha256 string) string
- type RemoveFileResult
- type RestoreFileResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PruneDirs ¶ added in v0.3.0
PruneDirs attempts to remove empty directories that were ancestors of the given relative paths, bounded by targetRoot. It is intended to be called after a set of file remove/restore operations to clean up directories that modctl emptied. Directories that are non-empty are silently skipped. Returns a slice of warning strings for any unexpected errors.
Types ¶
type DeployFileResult ¶
type DeployFileResult struct {
DestPath string
ContentSha256 string
SizeBytes int64
// WasBackedUp is true if a pre-existing file was backed up before writing
WasBackedUp bool
// BackupSha256 is set when WasBackedUp is true
BackupSha256 string
}
DeployFileResult is the outcome of deploying a single file during apply
type DeployOverrideFileResult ¶ added in v0.3.0
type DeployOverrideFileResult struct {
DestPath string
ContentSha256 string
SizeBytes int64
WasBackedUp bool
BackupSha256 string
}
DeployOverrideFileResult is the outcome of deploying an override file.
type Extractor ¶
Extractor handles archive extraction and file deployment
func (Extractor) CleanupStaging ¶
CleanupStaging removes the staging root directory entirely. Call this after a successful apply run unless --keep-staging is set.
func (Extractor) ClearStaging ¶
ClearStaging removes and recreates the staging root directory. Call this at the start of each apply run.
func (Extractor) DeployFile ¶
func (e Extractor) DeployFile( ctx context.Context, db *sql.DB, q *dbq.Queries, op planner.PlanOp, stagingPath string, targetRoot string, gameInstallID int64, targetID int64, profileID int64, operationID int64, ) (DeployFileResult, error)
DeployFile moves a single winning file from staging into the target directory. It:
- backs up any pre-existing non-tool-owned file if op.NeedsBackup is true
- copies the staged file to the target, hashing it in the process
- updates archive_inventory_entries.content_sha256 if not already set
- upserts the installed_files row
- inserts an operation_changes row
All DB writes are performed in a single transaction.
func (Extractor) DeployOverrideFile ¶ added in v0.3.0
func (e Extractor) DeployOverrideFile( ctx context.Context, db *sql.DB, q *dbq.Queries, op planner.PlanOp, stagingDir string, targetRoot string, gameInstallID int64, targetID int64, profileID int64, operationID int64, patchEntries []patchapply.Entry, ) (DeployOverrideFileResult, error)
DeployOverrideFile deploys a file whose content comes from an override rather than a mod archive. Handles both full_file and patch override types. For full_file overrides, content is read from the override blob store. For patch overrides, the base file is read from staging and patches are applied in memory before writing.
func (Extractor) ExtractArchive ¶
ExtractArchive extracts all contents of the archive identified by archiveSha256 into a per-archive staging directory. Returns the staging directory path.
func (Extractor) RemoveFile ¶
func (e Extractor) RemoveFile( ctx context.Context, db *sql.DB, q *dbq.Queries, op planner.PlanOp, targetRoot string, gameInstallID int64, targetID int64, operationID int64, ) (RemoveFileResult, error)
RemoveFile deletes a tool-managed file from disk and removes its installed_files row and inserts an operation_changes row. All DB writes are performed in a single transaction.
func (Extractor) RestoreFile ¶
func (e Extractor) RestoreFile( ctx context.Context, db *sql.DB, q *dbq.Queries, op planner.PlanOp, targetRoot string, gameInstallID int64, targetID int64, operationID int64, ) (RestoreFileResult, error)
RestoreFile copies a backup blob back to the target path, removes the installed_files row, deletes the backups row, and inserts an operation_changes row. All DB writes are in a single transaction.
func (Extractor) StagingPathFor ¶
StagingPathFor returns the staging directory for a given archive sha256
type RemoveFileResult ¶
type RemoveFileResult struct {
DestPath string
}
RemoveFileResult is the outcome of removing a single file during apply
type RestoreFileResult ¶
type RestoreFileResult struct {
DestPath string
}
RestoreFileResult is the outcome of restoring a backup during apply