rsync

package module
v0.0.0-...-f15d00b Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: Zlib Imports: 4 Imported by: 4

Documentation

Overview

RSync/RDiff implementation.

Algorithm found at: http://www.samba.org/~tridge/phd_thesis.pdf

Definitions

Source: The final content.
Target: The content to be made into final content.
Signature: The sequence of hashes used to identify the content.

Index

Constants

View Source
const DefaultBlockSize = 1024 * 6

If no BlockSize is specified in the RSync instance, this value is used.

View Source
const DefaultMaxDataOp = DefaultBlockSize * 10

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockHash

type BlockHash struct {
	Index      uint64
	StrongHash []byte
	WeakHash   uint32
}

Signature hash item generated from target.

type OpType

type OpType byte

Operation Types.

const (
	OpBlock OpType = iota
	OpData
	OpHash
	OpBlockRange
)

type Operation

type Operation struct {
	Type          OpType
	BlockIndex    uint64
	BlockIndexEnd uint64
	Data          []byte
}

Instruction to mutate target to align to source.

type OperationWriter

type OperationWriter func(op Operation) error

type RSync

type RSync struct {
	BlockSize int
	MaxDataOp int

	// If this is nil an MD5 hash is used.
	UniqueHasher hash.Hash
	// contains filtered or unexported fields
}

Properties to use while working with the rsync algorithm. A single RSync should not be used concurrently as it may contain internal buffers and hash sums.

func (*RSync) ApplyDelta

func (r *RSync) ApplyDelta(alignedTarget io.Writer, target io.ReadSeeker, ops chan Operation, alignedTargetSum hash.Hash) error

Apply the difference to the target. If alignedTargetSum is present the alignedTarget content will be written to it.

func (*RSync) BlockHashCount

func (r *RSync) BlockHashCount(targetLength int) (count int)

If the target length is known the number of hashes in the signature can be determined.

func (*RSync) CreateDelta

func (r *RSync) CreateDelta(source io.Reader, signature []BlockHash, ops OperationWriter, sourceSum hash.Hash) (err error)

Create the operation list to mutate the target signature into the source. Any data operation from the OperationWriter must have the data copied out within the span of the function; the data buffer underlying the operation data is reused. The sourceSum create a complete hash sum of the source if present.

func (*RSync) CreateSignature

func (r *RSync) CreateSignature(target io.Reader, sw SignatureWriter) error

Calculate the signature of target.

type SignatureWriter

type SignatureWriter func(bl BlockHash) error

Write signatures as they are generated.

Directories

Path Synopsis
A binary protocol for rsync.
A binary protocol for rsync.
RDiff clone.
RDiff clone.
Single-Buffer backing for readers.
Single-Buffer backing for readers.

Jump to

Keyboard shortcuts

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