aboutsummaryrefslogtreecommitdiff
path: root/repo.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-08-30 16:35:09 +0200
committern-peugnet <n.peugnet@free.fr>2021-08-30 16:35:09 +0200
commitad38e12c15af10a73447196ac0b0f1a5df8bf865 (patch)
treea02adbb35df7d3be67cb2134e05d463b595d271d /repo.go
parent05f21f3e95227f039d2b64bff4d123dd1edbdf5b (diff)
downloaddna-backup-ad38e12c15af10a73447196ac0b0f1a5df8bf865.tar.gz
dna-backup-ad38e12c15af10a73447196ac0b0f1a5df8bf865.zip
fix: chunkId added multiple times for same superFeature
Diffstat (limited to 'repo.go')
-rw-r--r--repo.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/repo.go b/repo.go
index 8df6fdf..457dadd 100644
--- a/repo.go
+++ b/repo.go
@@ -223,12 +223,25 @@ func hashChunks(chunks <-chan StoredChunk) (FingerprintMap, SketchMap) {
fingerprints[h] = c.Id()
sketch, _ := SketchChunk(c, 32, 3, 4)
for _, s := range sketch {
- sketches[s] = append(sketches[s], c.Id())
+ prev := sketches[s]
+ if contains(prev, c.Id()) {
+ continue
+ }
+ sketches[s] = append(prev, c.Id())
}
}
return fingerprints, sketches
}
+func contains(s []*ChunkId, id *ChunkId) bool {
+ for _, v := range s {
+ if v == id {
+ return true
+ }
+ }
+ return false
+}
+
func findSimilarChunk(chunk Chunk, sketches SketchMap) (*ChunkId, bool) {
var similarChunks = make(map[ChunkId]int)
var max int