check deleted chunks faster

This commit is contained in:
Chris Lu
2019-06-22 13:22:22 -07:00
parent cd45ab072a
commit 1babec00e7
2 changed files with 5 additions and 18 deletions

View File

@@ -74,16 +74,13 @@ func (f *Filer) deleteChunksIfNotNew(oldEntry, newEntry *Entry) {
}
var toDelete []*filer_pb.FileChunk
newChunkIds := make(map[string]bool)
for _, newChunk := range newEntry.Chunks {
newChunkIds[newChunk.GetFileIdString()] = true
}
for _, oldChunk := range oldEntry.Chunks {
found := false
for _, newChunk := range newEntry.Chunks {
if filer_pb.ChunkEquals(oldChunk, newChunk) {
found = true
break
}
}
if !found {
if _, found := newChunkIds[oldChunk.GetFileIdString()]; !found {
toDelete = append(toDelete, oldChunk)
}
}