diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-08-30 16:35:09 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-08-30 16:35:09 +0200 |
commit | ad38e12c15af10a73447196ac0b0f1a5df8bf865 (patch) | |
tree | a02adbb35df7d3be67cb2134e05d463b595d271d /repo.go | |
parent | 05f21f3e95227f039d2b64bff4d123dd1edbdf5b (diff) | |
download | dna-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.go | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -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 |