diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-06-22 13:22:22 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-06-22 13:22:22 -0700 |
| commit | 1babec00e70fc194fa40951162db907cf0e363cd (patch) | |
| tree | c195eaa7508d9ec537478c6968f47777068959cd /weed/filer2 | |
| parent | cd45ab072a8dba68773f995e130798e449b1791a (diff) | |
| download | seaweedfs-1babec00e70fc194fa40951162db907cf0e363cd.tar.xz seaweedfs-1babec00e70fc194fa40951162db907cf0e363cd.zip | |
check deleted chunks faster
Diffstat (limited to 'weed/filer2')
| -rw-r--r-- | weed/filer2/filer_deletion.go | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/weed/filer2/filer_deletion.go b/weed/filer2/filer_deletion.go index 574be8555..f8b09adf6 100644 --- a/weed/filer2/filer_deletion.go +++ b/weed/filer2/filer_deletion.go @@ -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) } } |
