Help us shape the future of Go! Take the 2026 Go Developer Survey

restore

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsafePaths = errors.New("bundle is not safe to import")

ErrUnsafePaths is the error of a bundle that has paths that would take what is done with them outside of the directory they are for.

Functions

func CheckPaths added in v0.9.0

func CheckPaths(ctx context.Context, bundle *Bundle) error

CheckPaths checks the paths in a bundle as strictly as a restore could: as if what is on disk was kept, which is the case of a restore on the same machine. It is for saying whether a bundle is fine to import, without importing it.

Types

type Bundle

type Bundle struct {
	Manifest  exporter.Manifest
	BundleDir string // temp dir where bundle was extracted
	BundleDB  *sql.DB
}

Bundle is the extracted, validated contents of an import bundle. It holds the temp directory and opened bundle DB until Close is called.

func OpenAndValidate

func OpenAndValidate(ctx context.Context, bundlePath string, scratchDir string, schema *database.Schema) (*Bundle, error)

OpenAndValidate extracts the bundle, verifies integrity, and returns a validated Bundle ready for import. Caller must call Close() when done.

The bundle is extracted to a directory of its own in scratchDir, which has to be there and to have room for all of the bundle (the blobs are in it, and that is most of it), and its database is brought to the schema schema. Neither is found by this function: nothing is made anywhere that it was not told.

func (*Bundle) Close

func (b *Bundle) Close()

type DisabledTarget added in v0.9.0

type DisabledTarget struct {
	Game     string
	Name     string
	RootPath string

	// Custom is whether it is a target that the user made: nothing on this
	// machine is going to confirm it.
	Custom bool
}

DisabledTarget is a target that was imported disabled.

type Options

type Options struct {
	SkipInventory bool
	Force         bool
	DryRun        bool
	SameMachine   bool
	Game          string // "store_id:store_game_id", only set when extracting a game from a full bundle
	CacheDBPath   string

	// Schema is the schema that the database that is restored is brought to,
	// and compared with the one that the bundle has. It is not found by the
	// restore.
	Schema *database.Schema
}

type Result

type Result struct {
	// counts of what was imported
	Archives         int
	Backups          int
	Overrides        int
	ModPages         int
	Profiles         int
	InventoryScanned int
	InventoryFailed  int

	// DisabledTargets are the targets that were imported disabled (see
	// targets.go), which the user is to be told about.
	DisabledTargets []DisabledTarget
}

func Full

func Full(
	ctx context.Context,
	db *sql.DB,
	q *dbq.Queries,
	bs blobstore.Store,
	bundle *Bundle,
	opts Options,
	dbPath string,
	modctlVersion string,
	logger *slog.Logger,
) (Result, error)

Full imports a full bundle into a fresh database.

func Game

func Game(
	ctx context.Context,
	db *sql.DB,
	q *dbq.Queries,
	bs blobstore.Store,
	bundle *Bundle,
	opts Options,
	modctlVersion string,
	logger *slog.Logger,
) (Result, error)

Game imports a game-scoped bundle into an existing database.

Jump to

Keyboard shortcuts

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