Documentation
¶
Overview ¶
Package extractor handles extraction of mod archives to a staging directory and deployment of files into the game target directory.
Index ¶
- type DeployFileResult
- 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) 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 ¶
This section is empty.
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 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) 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