restore

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package restore handles snapshot restore operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetHooksForTest

func SetHooksForTest(hooks Hooks) func()

Types

type Hooks

type Hooks struct {
	FsyncDir         func(string) error
	UpdateHead       func(*worktree.Manager, string, model.SnapshotID) error
	RecordPathSource func(repoRoot, worktreeName, relPath string, source model.SnapshotID) error
}

type IncompleteError

type IncompleteError struct {
	BackupPath        string
	PayloadRolledBack bool
	PathEntries       []PathBackupEntry
	// contains filtered or unexported fields
}

func AsIncompleteError

func AsIncompleteError(err error) (*IncompleteError, bool)

func (*IncompleteError) Error

func (e *IncompleteError) Error() string

func (*IncompleteError) Unwrap

func (e *IncompleteError) Unwrap() error

type PathBackupEntry

type PathBackupEntry struct {
	Path        string
	HadOriginal bool
}

type Restorer

type Restorer struct {
	// contains filtered or unexported fields
}

Restorer handles snapshot restore operations.

func NewRestorer

func NewRestorer(repoRoot string, engineType model.EngineType) *Restorer

NewRestorer creates a new restorer.

func (*Restorer) LastTransferRecord added in v0.4.7

func (r *Restorer) LastTransferRecord() (transfer.Record, bool)

LastTransferRecord returns the final primary restore materialization transfer from the most recent successful restore handled by this Restorer.

func (*Restorer) Restore

func (r *Restorer) Restore(worktreeName string, snapshotID model.SnapshotID) error

Restore replaces the content of a worktree with a snapshot. This puts the worktree into a "detached" state (unless restoring to HEAD). The worktree is specified by name, not derived from the snapshot.

func (*Restorer) RestoreLocked

func (r *Restorer) RestoreLocked(worktreeName string, snapshotID model.SnapshotID) error

RestoreLocked performs Restore while the caller already holds the repository mutation lock.

func (*Restorer) RestoreLockedWithOptions

func (r *Restorer) RestoreLockedWithOptions(worktreeName string, snapshotID model.SnapshotID, options RunOptions) error

func (*Restorer) RestorePath

func (r *Restorer) RestorePath(worktreeName string, snapshotID model.SnapshotID, path string) error

RestorePath replaces one workspace-relative file or directory from a save point without moving the workspace history or whole-workspace content source.

func (*Restorer) RestorePathLocked

func (r *Restorer) RestorePathLocked(worktreeName string, snapshotID model.SnapshotID, path string) error

RestorePathLocked performs RestorePath while the caller already holds the repository mutation lock.

func (*Restorer) RestorePathLockedWithOptions

func (r *Restorer) RestorePathLockedWithOptions(worktreeName string, snapshotID model.SnapshotID, path string, options RunOptions) error

func (*Restorer) RestoreToLatest

func (r *Restorer) RestoreToLatest(worktreeName string) error

RestoreToLatest restores a worktree to its latest snapshot (exits detached state).

type RunOptions

type RunOptions struct {
	BackupPath string
}

Jump to

Keyboard shortcuts

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