diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-08-30 14:34:55 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-08-30 14:34:55 +0200 |
commit | afc30e335fb45910cb441956b239fc0d8f89446f (patch) | |
tree | 6869adbbf007ec7d27a511af7cdd236ac785a44d | |
parent | ea34c64c5cd6d62af487a0db62bd64a2b467ec25 (diff) | |
download | dna-backup-afc30e335fb45910cb441956b239fc0d8f89446f.tar.gz dna-backup-afc30e335fb45910cb441956b239fc0d8f89446f.zip |
better diff test
-rw-r--r-- | TODO.md | 1 | ||||
-rw-r--r-- | repo.go | 1 | ||||
-rw-r--r-- | repo_test.go | 24 |
3 files changed, 14 insertions, 12 deletions
@@ -2,6 +2,7 @@ priority 1 ---------- - join non-deduplicated chunks - choose when and how to +- delta encode chunks - read from repo priority 2 @@ -242,6 +242,7 @@ func findSimilarChunk(chunk Chunk, sketches SketchMap) (*ChunkId, bool) { for _, id := range chunkIds { count := similarChunks[*id] count += 1 + log.Printf("Found %d %d time(s)", id, count) if count > max { similarChunk = id } diff --git a/repo_test.go b/repo_test.go index 3a4af68..cbb54df 100644 --- a/repo_test.go +++ b/repo_test.go @@ -187,22 +187,22 @@ func TestBsdiff(t *testing.T) { go concatFiles(files, writer) fingerprints, sketches := hashChunks(oldChunks) recipe := repo.matchStream(reader, fingerprints) - buff := new(bytes.Buffer) - r2 := recipe[2].Reader() - r0 := recipe[0].Reader() - bsdiff.Reader(r2, r0, buff) - log.Println("Diff size:", buff.Len()) - if buff.Len() < 500 { - t.Errorf("Bsdiff of chunk is too small: %d", buff.Len()) - } - if buff.Len() >= chunkSize { - t.Errorf("Bsdiff of chunk is too large: %d", buff.Len()) - } newChunks := extractNewChunks(recipe) log.Println("Checking new chunks:", len(newChunks[0])) for _, chunks := range newChunks { for _, c := range chunks { - log.Println(findSimilarChunk(c, sketches)) + id, exists := findSimilarChunk(c, sketches) + log.Println(id, exists) + if exists { + patch := new(bytes.Buffer) + stored := id.Reader(repo.path) + new := c.Reader() + bsdiff.Reader(stored, new, patch) + log.Println("Patch size:", patch.Len()) + if patch.Len() >= chunkSize/10 { + t.Errorf("Bsdiff of chunk is too large: %d", patch.Len()) + } + } } } } |