scanner

package
v0.10.16 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2015 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package scanner implements a file system scanner and hasher.

Index

Constants

This section is empty.

Variables

View Source
var SHA256OfNothing = []uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}

Functions

func BlockDiff

func BlockDiff(src, tgt []protocol.BlockInfo) (have, need []protocol.BlockInfo)

BlockDiff returns lists of common and missing (to transform src into tgt) blocks. Both block lists must have been created with the same block size.

func Blocks

func Blocks(r io.Reader, blocksize int, sizehint int64) ([]protocol.BlockInfo, error)

Blocks returns the blockwise hash of the reader.

func BlocksEqual added in v0.10.7

func BlocksEqual(src, tgt []protocol.BlockInfo) bool

BlockEqual returns whether two slices of blocks are exactly the same hash and index pair wise.

func HashFile added in v0.10.0

func HashFile(path string, blockSize int) ([]protocol.BlockInfo, error)

func PermsEqual

func PermsEqual(a, b uint32) bool

func PopulateOffsets added in v0.10.2

func PopulateOffsets(blocks []protocol.BlockInfo)

Set the Offset field on each block

func SymlinkTypeEqual added in v0.10.7

func SymlinkTypeEqual(disk, index uint32) bool

If the target is missing, Unix never knows what type of symlink it is and Windows always knows even if there is no target. Which means that without this special check a Unix node would be fighting with a Windows node about whether or not the target is known. Basically, if you don't know and someone else knows, just accept it. The fact that you don't know means you are on Unix, and on Unix you don't really care what the target type is. The moment you do know, and if something doesn't match, that will propogate throught the cluster.

func Verify added in v0.10.0

func Verify(r io.Reader, blocksize int, blocks []protocol.BlockInfo) error

Verify returns nil or an error describing the mismatch between the block list and actual reader contents

func VerifyBuffer added in v0.10.15

func VerifyBuffer(buf []byte, block protocol.BlockInfo) ([]byte, error)

Types

type CurrentFiler

type CurrentFiler interface {
	// CurrentFile returns the file as seen at last scan.
	CurrentFile(name string) protocol.FileInfo
}

type TempNamer

type TempNamer interface {
	// Temporary returns a temporary name for the filed referred to by filepath.
	TempName(path string) string
	// IsTemporary returns true if path refers to the name of temporary file.
	IsTemporary(path string) bool
}

type Walker

type Walker struct {
	// Dir is the base directory for the walk
	Dir string
	// Limit walking to this path within Dir, or no limit if Sub is blank
	Sub string
	// BlockSize controls the size of the block used when hashing.
	BlockSize int
	// If Matcher is not nil, it is used to identify files to ignore which were specified by the user.
	Matcher *ignore.Matcher
	// If TempNamer is not nil, it is used to ignore tempory files when walking.
	TempNamer TempNamer
	// Number of hours to keep temporary files for
	TempLifetime time.Duration
	// If CurrentFiler is not nil, it is queried for the current file before rescanning.
	CurrentFiler CurrentFiler
	// If IgnorePerms is true, changes to permission bits will not be
	// detected. Scanned files will get zero permission bits and the
	// NoPermissionBits flag set.
	IgnorePerms bool
}

func (*Walker) Walk

func (w *Walker) Walk() (chan protocol.FileInfo, error)

Walk returns the list of files found in the local folder by scanning the file system. Files are blockwise hashed.

Jump to

Keyboard shortcuts

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