snapshotfs

package
v0.3.0-pre2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: Apache-2.0 Imports: 24 Imported by: 7

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 SnapshotRoot

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

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

Types

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

	FilesPolicy ignorefs.FilesPolicyGetter

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

	// ignore file read errors
	IgnoreFileErrors bool

	// probability with hich hashcache entries will be ignored, must be [0..100]
	// 0=always use hash cache if possible
	// 100=never use hash cache
	ForceHashPercentage int

	// Do not hash-cache files younger than this age.
	// Protects from accidentally caching incorrect hashes of files that are being modified.
	HashCacheMinAge time.Duration

	// 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 cancelled.

func (*Uploader) Upload

func (u *Uploader) Upload(
	ctx context.Context,
	source fs.Entry,
	sourceInfo snapshot.SourceInfo,
	old *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