preprocess

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameePE  = "pe"   // PENormalizer
	NameNTFS = "ntfs" // NTFSTimestampNormalizer

)

Stable, persisted names for each normalizer. These are written into the repository config so that read paths (restore, verify, index rebuild, prune) can reconstruct exactly the normalizer the backup used — the chunk identity hash is computed over normalized bytes but the original bytes are stored, so verification must re-normalize with the same normalizer.

Variables

This section is empty.

Functions

func IdentityHashInput

func IdentityHashInput(n Normalizer, data []byte) []byte

IdentityHashInput returns the bytes whose SHA-256 is the chunk identity: the normalized form when a normalizer is set, otherwise data unchanged. Read paths use this to verify stored (original) chunk bytes against the normalized identity hash recorded in the manifest.

func Names

func Names(n Normalizer) []string

Names returns the stable persisted name(s) for a normalizer, flattening a CompositeNormalizer into its parts. Returns nil for a nil or no-op normalizer.

Types

type CompositeNormalizer

type CompositeNormalizer struct {
	Normalizers []Normalizer
}

CompositeNormalizer chains multiple normalizers, piping the output of each into the next.

func (*CompositeNormalizer) Normalize

func (c *CompositeNormalizer) Normalize(data []byte) []byte

type NTFSTimestampNormalizer

type NTFSTimestampNormalizer struct{}

NTFSTimestampNormalizer zeros the four 8-byte timestamps in $STANDARD_INFORMATION (0x10) attributes of MFT records. These timestamps differ across machines even for identical files, hurting cross-machine dedup. Only the hash input is modified; original data is stored faithfully.

func (*NTFSTimestampNormalizer) Normalize

func (n *NTFSTimestampNormalizer) Normalize(data []byte) []byte

Normalize scans for MFT "FILE" records at 1024-byte boundaries and zeros the 32 bytes of timestamps in each $STANDARD_INFORMATION attribute.

type NoopNormalizer

type NoopNormalizer struct{}

NoopNormalizer passes data through unchanged.

func (*NoopNormalizer) Normalize

func (n *NoopNormalizer) Normalize(data []byte) []byte

type Normalizer

type Normalizer interface {
	// Normalize returns a normalized copy of data for hashing purposes.
	// The original data is never modified.
	Normalize(data []byte) []byte
}

Normalizer transforms chunk data before hashing to improve dedup across semantically-identical-but-byte-different content.

func FromNames

func FromNames(names []string) (Normalizer, error)

FromNames reconstructs a Normalizer from persisted names. It returns nil when names is empty (no normalization). The order of names is preserved so composite normalization is reproduced exactly.

type PENormalizer

type PENormalizer struct{}

PENormalizer zeros PE header timestamps and checksums to improve dedup of Windows executables across builds.

func (*PENormalizer) Normalize

func (n *PENormalizer) Normalize(data []byte) []byte

Normalize zeros TimeDateStamp and CheckSum fields in any PE headers found within the data. Returns a copy; the original is unmodified.

Jump to

Keyboard shortcuts

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