sure

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2018 License: BSD-3-Clause Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SyntaxError = errors.New("Syntax error in surefile")

Functions

func CompareTrees

func CompareTrees(older, newer *Tree)

Traverse an old tree and a new tree, printing out everything that is different between them.

func MigrateHashes

func MigrateHashes(oldTree, newTree *Tree)

Migrate hashes from oldTree to newTree. Any files that are the same in the oldTree as the newTree will have their hash migrated to the new tree.

Types

type AttMap

type AttMap interface {
	GetKind() string
}

AttMap defines an interface to general attributes for file nodes.

type BaseAtts

type BaseAtts struct {
	Uid  uint32
	Gid  uint32
	Perm uint32
}

BaseAtts are attributes associated with all most types.

type Comparer

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

The Comparer is a writer where the diffs between two trees will be written.

func NewComparer

func NewComparer(w io.Writer) Comparer

func (Comparer) CompareTrees

func (w Comparer) CompareTrees(older, newer *Tree)

type DevAtts

type DevAtts struct {
	Kind uint32
	BaseAtts
	Rdev uint64
}

DevAtts is for block and character nodes.

func (*DevAtts) GetKind

func (a *DevAtts) GetKind() string

type DirAtts

type DirAtts struct {
	BaseAtts
}

func (*DirAtts) GetKind

func (r *DirAtts) GetKind() string

type Estimate

type Estimate struct {
	Files uint64
	Bytes uint64
}

A hash estimate

type FifoAtts

type FifoAtts struct {
	Kind uint32
	BaseAtts
}

FifoAtts is for both fifos and sockets.

func (*FifoAtts) GetKind

func (a *FifoAtts) GetKind() string

type File

type File struct {
	Name string
	Atts AttMap
}

A non-directory node (not necessarily a plain file)

type LinkAtts

type LinkAtts struct {
	BaseAtts
	Targ string
}

func (*LinkAtts) GetKind

func (r *LinkAtts) GetKind() string

type Progress

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

A progress meter. Records files visited, and number of bytes processed. When given an estimate, prints a simple periodic report of how far along we think we are.

func NewProgress

func NewProgress(files, bytes uint64, wr io.Writer) Progress

func (*Progress) Flush

func (p *Progress) Flush()

Flush the output, regardless of any update needed.

func (*Progress) Update

func (p *Progress) Update(files, bytes uint64)

Update the progress meter, displaying it if enough time has elapsed.

type PushDecoder

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

A PushDecoder is a stateful decoder that can be given a surefile one line at a time, and generate the full tree.

func NewPushDecoder

func NewPushDecoder() *PushDecoder

func (*PushDecoder) Add

func (pd *PushDecoder) Add(line string) error

Add adds a line to the push decoder.

func (*PushDecoder) Tree

func (pd *PushDecoder) Tree() (*Tree, error)

Tree extracts the tree from the push decoder. Returns an error if a full surefile wasn't pushed to it.

type RegAtts

type RegAtts struct {
	BaseAtts
	Mtime int64 // TODO: Store better than seconds.
	Ctime int64 // TODO: Store better than seconds.
	Ino   uint64
	Size  int64
	Sha1  []byte
}

func (*RegAtts) GetKind

func (r *RegAtts) GetKind() string

type Tree

type Tree struct {
	Name     string
	Atts     AttMap
	Children []*Tree
	Files    []*File
}

A directory tree node.

func Decode

func Decode(r io.Reader) (*Tree, error)

Decode loads a surefile from an io.Reader.

func GenerateTree

func GenerateTree(rand *rand.Rand, size, depth int) *Tree

Generate a random tree for testing.

func ScanFs

func ScanFs(path string, meter io.Writer) (tree *Tree, err error)

Walk a directory tree, generating a tree structure for it. All attributes are filled in that can be gleaned through lstat (and possibly readlink). The files themselves are not opened.

func (*Tree) ComputeHashes

func (t *Tree) ComputeHashes(prog *Progress, dir string)

Update all of the file nodes that don't have hashes.

func (*Tree) Encode

func (t *Tree) Encode(w io.Writer) error

Encode the sure tree to the given writer.

func (*Tree) EstimateHashes

func (t *Tree) EstimateHashes() Estimate

Estimate the amount of updates necessary to files hashes.

Jump to

Keyboard shortcuts

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