snapshotfs

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: Apache-2.0 Imports: 24 Imported by: 10

Documentation

Overview

Package snapshotfs implements virtual filesystem on top of snapshots in repo.Repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllSourcesEntry

func AllSourcesEntry(rep *repo.Repository) fs.Directory

AllSourcesEntry returns fs.Directory that contains the list of all snapshot sources found in the repository.

func DirectoryEntry

func DirectoryEntry(rep *repo.Repository, objectID object.ID, dirSummary *fs.DirectorySummary) fs.Directory

DirectoryEntry returns fs.Directory based on repository object with the specified ID. The existence or validity of the directory object is not validated until its contents are read.

func EntryFromDirEntry added in v0.4.0

func EntryFromDirEntry(r *repo.Repository, md *snapshot.DirEntry) (fs.Entry, error)

EntryFromDirEntry returns a filesystem entry based on the directory entry.

func Restore added in v0.4.0

func Restore(ctx context.Context, rep *repo.Repository, targetPath string, snapID manifest.ID, opts localfs.CopyOptions) error

Restore walks a snapshot root with given snapshot ID and restores it to the local filesystem

func RestoreRoot added in v0.4.0

func RestoreRoot(ctx context.Context, rep *repo.Repository, targetPath string, oid object.ID, opts localfs.CopyOptions) error

RestoreRoot walks a snapshot root with given object ID and restores it to the local filesystem

func SnapshotRoot

func SnapshotRoot(rep *repo.Repository, man *snapshot.Manifest) (fs.Entry, error)

SnapshotRoot returns fs.Entry representing the root of a snapshot.

Types

type TreeWalker

type TreeWalker struct {
	Parallelism    int
	RootEntries    []fs.Entry
	ObjectCallback func(entry fs.Entry) error
	// EntryID extracts or generates an id from an fs.Entry.
	// It can be used to eliminate duplicate entries when in a FS
	EntryID func(entry fs.Entry) interface{}
	// contains filtered or unexported fields
}

TreeWalker holds information for concurrently walking down FS trees specified by their roots

func NewTreeWalker

func NewTreeWalker() *TreeWalker

NewTreeWalker creates new tree walker.

func (*TreeWalker) Run

func (w *TreeWalker) Run(ctx context.Context) error

Run walks the given tree roots

type UploadProgress

type UploadProgress interface {
	Progress(path string, numFiles int, pathCompleted, pathTotal int64, stats *snapshot.Stats)
	UploadFinished()
}

UploadProgress is invoked by by uploader to report status of file and directory uploads.

type Uploader

type Uploader struct {
	Progress UploadProgress

	// automatically cancel the Upload after certain number of bytes
	MaxUploadBytes int64

	// ignore file read errors
	IgnoreFileErrors bool

	// probability with cached entries will be ignored, must be [0..100]
	// 0=always use cached object entries if possible
	// 100=never use cached entries
	ForceHashPercentage int

	// Number of files to hash and upload in parallel.
	ParallelUploads int
	// contains filtered or unexported fields
}

Uploader supports efficient uploading files and directories to repository.

func NewUploader

func NewUploader(r *repo.Repository) *Uploader

NewUploader creates new Uploader object for a given repository.

func (*Uploader) Cancel

func (u *Uploader) Cancel()

Cancel requests cancellation of an upload that's in progress. Will typically result in an incomplete snapshot.

func (*Uploader) IsCancelled

func (u *Uploader) IsCancelled() bool

IsCancelled returns true if the upload is canceled.

func (*Uploader) Upload

func (u *Uploader) Upload(
	ctx context.Context,
	source fs.Entry,
	policyTree *policy.Tree,
	sourceInfo snapshot.SourceInfo,
	previousManifests ...*snapshot.Manifest,
) (*snapshot.Manifest, error)

Upload uploads contents of the specified filesystem entry (file or directory) to the repository and returns snapshot.Manifest with statistics. Old snapshot manifest, when provided can be used to speed up uploads by utilizing hash cache.

Jump to

Keyboard shortcuts

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