transferarchiver

package
v1.0.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//TarArchiverKey configures the one object key returned by the tar Archiver
	TarArchiverKey = "archive.tar"

	//TarArchiverPathSeparator standardizes the header path for cross platform (un)archiving
	TarArchiverPathSeparator = "/"

	//ErrNoSuchDirectory is returned when an archiver expected a directory to exist
	ErrNoSuchDirectory = errors.New("directory doesn't exist")

	//ErrEmptyDirectory is returned when the archiver expected the directory to not be empty
	ErrEmptyDirectory = errors.New("directory is empty")

	//ErrDatasetTooLarge is returned when the dataset size is above 1Gb
	ErrDatasetTooLarge = errors.New("dataset is too big, limit is 1Gb")

	//SizeLimit is the maximum size allowed
	//@TODO: Should be based on customer details?
	SizeLimit = int64(1 * 1024 * 1024 * 1024)
)

Functions

This section is empty.

Types

type ArchiverOptions

type ArchiverOptions struct {
	Type ArchiverType `json:"type"`

	TarArchiverKeyPrefix string `json:"keyPrefix"`
}

ArchiverOptions contain options for all stores

type ArchiverType

type ArchiverType string

ArchiverType determines what type the object store will be

const (
	//ArchiverTypeTar uses the tar archiving format
	ArchiverTypeTar ArchiverType = "tar"
)

type Reporter

type Reporter interface {
	StartArchivingProgress(label string, total int64) func(int64)
	StopArchivingProgress()
	StartUnarchivingProgress(label string, total int64, rr io.Reader) io.Reader
	StopUnarchivingProgress()
}

Reporter describes how an archiver reports

type TarArchiver

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

TarArchiver will archive a directory into a single tar file

func NewTarArchiver

func NewTarArchiver(opts ArchiverOptions) (a *TarArchiver, err error)

NewTarArchiver will setup the tar archiver

func (*TarArchiver) Archive

func (a *TarArchiver) Archive(path string, rep Reporter, fn func(k string, r io.ReadSeeker, nbytes int64) error) (err error)

Archive will archive a directory at 'path' into readable objects 'r' and calls 'fn' for each

func (*TarArchiver) Index

func (a *TarArchiver) Index(fn func(k string) error) error

Index calls 'fn' for all object keys that are part of the archive

func (*TarArchiver) Unarchive

func (a *TarArchiver) Unarchive(path string, rep Reporter, fn func(k string, w io.WriterAt) error) error

Unarchive will take a file system path and call 'fn' for each object that it needs for unarchiving. It writes to a temporary directory first and then moves this to the final location

Jump to

Keyboard shortcuts

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