snapshot

package
v0.9.3-rc3 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name    string    `json:"name"`         // filename
	Size    int64     `json:"size"`         // file size
	ModTime time.Time `json:"lastModified"` // last modified time
}

File represents a single file in a manifest.

type FileWriter

type FileWriter interface {
	io.WriterTo
	io.Closer
}

FileWriter is the interface used for writing a file to a snapshot.

type Files

type Files []File

Files represents a sortable list of files.

func (Files) Len

func (p Files) Len() int

func (Files) Less

func (p Files) Less(i, j int) bool

func (Files) Swap

func (p Files) Swap(i, j int)

type Manifest

type Manifest struct {
	Files []File `json:"files"`
}

Manifest represents a list of files in a snapshot.

func ReadFileManifest

func ReadFileManifest(path string) (*Manifest, error)

ReadFileManifest returns a Manifest for a given base snapshot path. This merges all incremental backup manifests as well.

func (*Manifest) Diff

func (m *Manifest) Diff(other *Manifest) *Manifest

Diff returns a Manifest of files that are newer in m than other.

func (*Manifest) Merge

func (m *Manifest) Merge(other *Manifest) *Manifest

Merge returns a Manifest that combines m with other. Only the newest file between the two snapshots is returned.

type MultiReader

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

MultiReader reads from a collection of snapshots. Only files with the highest index are read from the reader. This type is not safe for concurrent use.

func NewMultiReader

func NewMultiReader(readers ...io.Reader) *MultiReader

NewMultiReader returns a new MultiReader reading from a list of readers.

func OpenFileMultiReader

func OpenFileMultiReader(path string) (*MultiReader, []io.Closer, error)

OpenFileMultiReader returns a MultiReader based on the path of the base snapshot. Returns the underlying files which need to be closed separately.

func (*MultiReader) Manifest

func (ssr *MultiReader) Manifest() (*Manifest, error)

Manifest returns the combined manifest from all readers.

func (*MultiReader) Next

func (ssr *MultiReader) Next() (File, error)

Next returns the next file in the reader.

func (*MultiReader) Read

func (ssr *MultiReader) Read(b []byte) (n int, err error)

Read reads the current entry in the reader.

type Reader

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

Reader reads a snapshot from a Reader. This type is not safe for concurrent use.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns a new Reader reading from r.

func (*Reader) Manifest

func (sr *Reader) Manifest() (*Manifest, error)

Manifest returns the snapshot manifest.

func (*Reader) Next

func (sr *Reader) Next() (File, error)

Next returns the next file in the snapshot.

func (*Reader) Read

func (sr *Reader) Read(b []byte) (n int, err error)

Read reads the current entry in the snapshot.

type Writer

type Writer struct {
	// The manifest to write from.
	// Removing files from the manifest after creation will cause those files to be ignored.
	Manifest *Manifest

	// Writers for each file by filename.
	// Writers will be closed as they're processed and will close by the end of WriteTo().
	FileWriters map[string]FileWriter
}

Writer writes a snapshot and the underlying files to disk as a tar archive.

func NewWriter

func NewWriter() *Writer

NewWriter returns a new instance of Writer.

func (*Writer) Close

func (sw *Writer) Close() error

Close closes all file writers on the snapshot.

func (*Writer) WriteTo

func (sw *Writer) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes the snapshot to the writer. File writers are closed as they are written. This function will always return n == 0.

Jump to

Keyboard shortcuts

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