snapshot

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package snapshot manages file tree snapshots created by the "fsdiff snapshot" command.

Index

Constants

View Source
const FormatVersion = 1

FormatVersion represents the current snapshot file format version.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal serializes <v> in raw data for Storage in the snapshot database.

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal deserializes Snapshot database <data> into <v>.

Types

type CreateOpt

type CreateOpt func(c *createSnapshotOptions)

CreateOpt represents a Snapshot creation option.

func CreateOptCarryOn

func CreateOptCarryOn() CreateOpt

CreateOptCarryOn sets the Snapshot creation to continue in case of filesystem error.

func CreateOptExclude

func CreateOptExclude(v []string) CreateOpt

CreateOptExclude sets at list of gitignore-compatible exclusion pattern.

func CreateOptShallow

func CreateOptShallow() CreateOpt

CreateOptShallow sets the Snapshot creation to skip files checksum computation.

type FileInfo

type FileInfo struct {
	Path     string
	Size     int64
	Mtime    time.Time
	Uid      uint32 // FIXME: rename field to "UID" during next snapshot format version increment
	Gid      uint32 // FIXME: rename field to "GID" during next snapshot format version increment
	Mode     os.FileMode
	LinkTo   string
	IsDir    bool
	IsSock   bool
	IsPipe   bool
	IsDev    bool
	Checksum []byte
}

FileInfo represents information about a file referenced in a Snapshot.

func (*FileInfo) String

func (f *FileInfo) String() string

String implements the fmt.Stringer interface.

type Metadata

type Metadata struct {
	// FormatVersion is the snapshot format version, for backward compatibility.
	FormatVersion int

	// FsdiffVersion is the version of the "fsdiff" command that has been used to create the snapshot.
	FsdiffVersion string

	// Date is the date when the snapshot has been created.
	Date time.Time

	// RootDir is the absolute path to the snapshotted root directory.
	RootDir string

	// Shallow indicates if the snapshot has been done in "shallow" mode.
	Shallow bool
}

Metadata represent a Snapshot metadata.

type Snapshot

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

Snapshot represents a filesystem snapshot.

func Create

func Create(outFile, root string, opts ...CreateOpt) (*Snapshot, error)

Create creates a new Snapshot of directory <root> to be stored to file <outFile>. If the <shallow> argument is true, the snapshot will be performed in "shallow" mode (i.e. without computing files checksum).

func Open

func Open(path string) (*Snapshot, error)

Open opens the Snapshot file at <path> in read-only mode.

func (*Snapshot) Close

func (s *Snapshot) Close() error

Close closes the Snapshot database session.

func (*Snapshot) FilesByChecksum

func (s *Snapshot) FilesByChecksum() ([]*FileInfo, error)

FilesByChecksum returns a list of FileInfo referenced by checksum in the Snapshot.

func (*Snapshot) FilesByPath

func (s *Snapshot) FilesByPath() ([]*FileInfo, error)

FilesByPath returns a list of FileInfo referenced by path in the Snapshot.

func (*Snapshot) Metadata

func (s *Snapshot) Metadata() *Metadata

Metadata returns the Snapshot metadata.

func (*Snapshot) Read

func (s *Snapshot) Read(readFunc func(byPath, byChecksum *bolt.Bucket) error) error

Read executes the <readFunc> function in a read-only transaction of the Snapshot database.

func (*Snapshot) Write

func (s *Snapshot) Write(writeFunc func(byPath, byChecksum *bolt.Bucket) error) error

Write executes the <writeFunc> function in a read-write transaction of the Snapshot database.

Jump to

Keyboard shortcuts

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