diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-09-01 19:07:49 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-09-01 19:07:49 +0200 |
commit | 1dec2cdc84a6497c893d84485c6f94589f997215 (patch) | |
tree | 690a3a1601c54ea77878a9fae8429beac46c5919 /repo.go | |
parent | db40818ef79ccb3f5f9232623f57ad284a4af7d0 (diff) | |
download | dna-backup-1dec2cdc84a6497c893d84485c6f94589f997215.tar.gz dna-backup-1dec2cdc84a6497c893d84485c6f94589f997215.zip |
Prepare for delta encoding
Diffstat (limited to 'repo.go')
-rw-r--r-- | repo.go | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 |