differ

package
v0.0.0-...-9644588 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Differ

type Differ struct{}

Differ handles binary diff operations

func NewDiffer

func NewDiffer() *Differ

NewDiffer creates a new differ

func (*Differ) ApplyPatch

func (d *Differ) ApplyPatch(oldFilePath string, patchData []byte) ([]byte, error)

ApplyPatch applies a binary patch to a file

func (*Differ) ApplyPatchToData

func (d *Differ) ApplyPatchToData(oldData, patchData []byte) ([]byte, error)

ApplyPatchToData applies a binary patch to byte data

func (*Differ) ApplyPatchToFile

func (d *Differ) ApplyPatchToFile(oldFilePath, outputPath string, patchData []byte) error

ApplyPatchToFile applies a binary patch and writes the result to a file

func (*Differ) CompareSizes

func (d *Differ) CompareSizes(oldSize, newSize int64) (delta int64, percent float64)

CompareSizes returns the size difference between old and new data

func (*Differ) CopyFileChunked

func (d *Differ) CopyFileChunked(srcPath, dstPath string, chunkSize int64, progressCallback func(processed, total int64)) error

CopyFileChunked copies a large file in chunks without loading entire file into memory

func (*Differ) EstimatePatchSize

func (d *Differ) EstimatePatchSize(oldSize, newSize int64, similarity float64) int64

EstimatePatchSize estimates the patch size based on file sizes This is a rough estimate and actual size may vary

func (*Differ) GenerateDiff

func (d *Differ) GenerateDiff(oldFilePath, newFilePath string) ([]byte, error)

GenerateDiff generates a binary diff between two files

func (*Differ) GenerateDiffChunked

func (d *Differ) GenerateDiffChunked(oldFilePath, newFilePath string, chunkSize int64, progressCallback func(processed, total int64)) (string, int64, error)

GenerateDiffChunked generates a diff for very large files by processing in chunks For large files (>1GB), this uses full file replacement instead of binary diff: - Binary diff (bsdiff) requires loading both files fully into memory (e.g., 2x1.5GB = 3GB) - For large files, full replacement is more memory-efficient and reliable - Returns the source file path so caller can stream it directly - Applier will handle this as a full file replacement, copying in chunks

func (*Differ) GenerateDiffFromData

func (d *Differ) GenerateDiffFromData(oldData, newData []byte) ([]byte, error)

GenerateDiffFromData generates a binary diff from byte slices

func (*Differ) GenerateDiffStreaming

func (d *Differ) GenerateDiffStreaming(oldFilePath, newFilePath string, output io.Writer) error

GenerateDiffStreaming generates a binary diff for large files using streaming

func (*Differ) IsLargeFile

func (d *Differ) IsLargeFile(filePath string) (bool, int64, error)

IsLargeFile checks if a file exceeds the large file threshold

func (*Differ) ValidatePatch

func (d *Differ) ValidatePatch(patchData []byte) error

ValidatePatch validates that patch data appears to be valid bsdiff format

Jump to

Keyboard shortcuts

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