Documentation
¶
Index ¶
- Constants
- func AlwaysMatch(path string, f *os.FileInfo) bool
- func CalcStrong(dir Dir) string
- func IndexFile(path string) (fileInfo *FileInfo, blocksInfo []*BlockInfo, err os.Error)
- func Move(src string, dst string) (err os.Error)
- func PostOrderWalk(path string, visitor filepath.Visitor, errors chan<- os.Error)
- func RelPath(item FsNode) string
- func SplitNames(path string) []string
- func StrongChecksum(buf []byte) string
- func Walk(node Node, visitor NodeVisitor)
- type Block
- type BlockInfo
- type BlockStore
- type Blocks
- type Dir
- type DirInfo
- type Dirs
- type File
- type FileInfo
- type Files
- type FsNode
- type IndexFilter
- type Indexer
- type LocalDirStore
- func (store LocalDirStore) ReadBlock(strong string) ([]byte, os.Error)
- func (store LocalDirStore) ReadInto(strong string, from int64, length int64, writer io.Writer) (int64, os.Error)
- func (store LocalDirStore) RelPath(fullpath string) (relpath string)
- func (store LocalDirStore) Relocate(fullpath string) (relocFullpath string, err os.Error)
- func (store LocalDirStore) Repo() NodeRepo
- func (store LocalDirStore) Resolve(relpath string) string
- func (store *LocalDirStore) Root() FsNode
- func (store LocalDirStore) RootPath() string
- type LocalFileStore
- func (store LocalFileStore) ReadBlock(strong string) ([]byte, os.Error)
- func (store *LocalFileStore) ReadInto(strong string, from int64, length int64, writer io.Writer) (int64, os.Error)
- func (store LocalFileStore) RelPath(fullpath string) (relpath string)
- func (store LocalFileStore) Relocate(fullpath string) (relocFullpath string, err os.Error)
- func (store LocalFileStore) Repo() NodeRepo
- func (store *LocalFileStore) Resolve(_ string) string
- func (store *LocalFileStore) Root() FsNode
- func (store LocalFileStore) RootPath() string
- type LocalStore
- type MemRepo
- func (repo *MemRepo) AddBlock(file File, info *BlockInfo) Block
- func (repo *MemRepo) AddDir(dir Dir, info *DirInfo) Dir
- func (repo *MemRepo) AddFile(dir Dir, fileInfo *FileInfo, blocksInfo []*BlockInfo) File
- func (repo *MemRepo) Block(strong string) (block Block, has bool)
- func (repo *MemRepo) Close()
- func (repo *MemRepo) Dir(strong string) (dir Dir, has bool)
- func (repo *MemRepo) File(strong string) (file File, has bool)
- func (repo *MemRepo) IndexFilter() IndexFilter
- func (repo *MemRepo) Root() FsNode
- func (repo *MemRepo) WeakBlock(weak int) (block Block, has bool)
- type Node
- type NodeRepo
- type NodeVisitor
- type WeakChecksum
Constants ¶
const BLOCKSIZE int = 8192
Block size used for checksum, comparison, transmitting deltas.
const RELOC_PREFIX string = "_reloc"
Variables ¶
This section is empty.
Functions ¶
func Move ¶
Move src to dst. Try a rename. If that fails due to different filesystems, try a copy/delete instead.
func PostOrderWalk ¶
func RelPath ¶
Given a filesystem node, calculate the relative path string to it from the root node.
func SplitNames ¶
func StrongChecksum ¶
Strong checksum algorithm used throughout replican For now, it's SHA-1.
func Walk ¶
func Walk(node Node, visitor NodeVisitor)
Traverse the hierarchical tree model with a user-defined NodeVisitor function.
Types ¶
type BlockInfo ¶
Represent a block in a hierarchical tree model. Blocks are BLOCKSIZE chunks of data which comprise files.
func IndexBlock ¶
Model a block with weak and strong checksums.
type BlockStore ¶
type BlockStore interface { Repo() NodeRepo // Given a strong checksum of a block, get the bytes for that block. ReadBlock(strong string) ([]byte, os.Error) // Given the strong checksum of a file, start and end positions, get those bytes. ReadInto(strong string, from int64, length int64, writer io.Writer) (int64, os.Error) }
Provide access to the raw byte storage.
type FileInfo ¶
type FileInfo struct { Name string Mode uint32 // TODO: move to repo wrapper? Size int64 Strong string Parent string }
Represent a file in a hierarchical tree model.
type FsNode ¶
type FsNode interface { // FsNode extends the concept of Node. Node // All FsNodes have names (file or directory name). Name() string Mode() uint32 }
FsNodes are members of a hierarchical index that map directly onto the filesystem: files and directories.
type IndexFilter ¶
func AllMatch ¶
func AllMatch(filters ...IndexFilter) IndexFilter
func AnyMatch ¶
func AnyMatch(filters ...IndexFilter) IndexFilter
type Indexer ¶
type Indexer struct { Path string Repo NodeRepo Filter IndexFilter Errors chan<- os.Error // contains filtered or unexported fields }
type LocalDirStore ¶
type LocalDirStore struct {
// contains filtered or unexported fields
}
func (*LocalDirStore) Root ¶
func (store *LocalDirStore) Root() FsNode
type LocalFileStore ¶
type LocalFileStore struct {
// contains filtered or unexported fields
}
func (*LocalFileStore) Resolve ¶
func (store *LocalFileStore) Resolve(_ string) string
func (*LocalFileStore) Root ¶
func (store *LocalFileStore) Root() FsNode
type LocalStore ¶
type LocalStore interface { BlockStore RelPath(fullpath string) (relpath string) Relocate(fullpath string) (relocFullpath string, err os.Error) Resolve(relpath string) string RootPath() string // contains filtered or unexported methods }
A local file implementation of BlockStore
func NewLocalStore ¶
func NewLocalStore(rootPath string, repo NodeRepo) (local LocalStore, err os.Error)
type MemRepo ¶
type MemRepo struct {
// contains filtered or unexported fields
}
func NewMemRepo ¶
func NewMemRepo() *MemRepo
func (*MemRepo) IndexFilter ¶
func (repo *MemRepo) IndexFilter() IndexFilter
type Node ¶
type Node interface { Repo() NodeRepo // Get the node that contains this node in the hierarchical index. Parent() (FsNode, bool) }
Nodes are any member of a hierarchical tree model representing a part of the filesystem. Nodes include files and directories, and also blocks within the files.
type NodeRepo ¶
type NodeRepo interface { Root() FsNode WeakBlock(weak int) (Block, bool) Block(strong string) (Block, bool) File(strong string) (File, bool) Dir(strong string) (Dir, bool) AddBlock(file File, blockInfo *BlockInfo) Block AddFile(dir Dir, fileInfo *FileInfo, blocksInfo []*BlockInfo) File AddDir(dir Dir, subdirInfo *DirInfo) Dir Close() IndexFilter() IndexFilter }
type NodeVisitor ¶
Visitor function to traverse a hierarchical tree model.
type WeakChecksum ¶
type WeakChecksum struct {
// contains filtered or unexported fields
}
Represent a weak checksum as described in the rsync algorithm paper
func (*WeakChecksum) Roll ¶
func (weak *WeakChecksum) Roll(removedByte byte, newByte byte)
Roll the checksum forward by one byte
func (*WeakChecksum) Write ¶
func (weak *WeakChecksum) Write(buf []byte)
Write a block of data into the checksum