aboutsummaryrefslogtreecommitdiff
path: root/repo.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-09-01 19:07:49 +0200
committern-peugnet <n.peugnet@free.fr>2021-09-01 19:07:49 +0200
commit1dec2cdc84a6497c893d84485c6f94589f997215 (patch)
tree690a3a1601c54ea77878a9fae8429beac46c5919 /repo.go
parentdb40818ef79ccb3f5f9232623f57ad284a4af7d0 (diff)
downloaddna-backup-1dec2cdc84a6497c893d84485c6f94589f997215.tar.gz
dna-backup-1dec2cdc84a6497c893d84485c6f94589f997215.zip
Prepare for delta encoding
Diffstat (limited to 'repo.go')
-rw-r--r--repo.go18
1 files changed, 18 insertions, 0 deletions
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