From 1dec2cdc84a6497c893d84485c6f94589f997215 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Wed, 1 Sep 2021 19:07:49 +0200 Subject: Prepare for delta encoding --- repo.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'repo.go') diff --git a/repo.go b/repo.go index 6f177c2..32666f4 100644 --- a/repo.go +++ b/repo.go @@ -48,6 +48,8 @@ type Repo struct { sketchWSize int sketchSfCount int sketchFCount int + differ Differ + patcher Patcher } type File struct { @@ -63,9 +65,19 @@ func NewRepo(path string) *Repo { sketchWSize: 32, sketchSfCount: 3, sketchFCount: 4, + differ: &Bsdiff{}, + patcher: &Bsdiff{}, } } +func (r *Repo) Differ() Differ { + return r.differ +} + +func (r *Repo) Patcher() Patcher { + return r.patcher +} + func (r *Repo) Commit(source string) { versions := r.loadVersions() newVersion := len(versions) @@ -275,6 +287,12 @@ func (r *Repo) findSimilarChunk(chunk Chunk, sketches SketchMap) (*ChunkId, bool return similarChunk, similarChunk != nil } +// TODO: encode stream +func (r *Repo) encodeStream(stream io.Reader, fingerprints FingerprintMap, sketches SketchMap) []Chunk { + chunks := r.matchStream(stream, fingerprints) + return chunks +} + func (r *Repo) matchStream(stream io.Reader, fingerprints FingerprintMap) []Chunk { var b byte var chunks []Chunk -- cgit v1.2.3