simplify
This commit is contained in:
@@ -2,7 +2,6 @@ package filer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/seaweedfs/seaweedfs/weed/storage"
|
"github.com/seaweedfs/seaweedfs/weed/storage"
|
||||||
"math"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -138,47 +137,19 @@ func (f *Filer) DeleteChunksNotRecursive(chunks []*filer_pb.FileChunk) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Filer) deleteChunksIfNotNew(oldEntry, newEntry *Entry) {
|
func (f *Filer) deleteChunksIfNotNew(oldEntry, newEntry *Entry) {
|
||||||
|
var oldChunks, newChunks []*filer_pb.FileChunk
|
||||||
if oldEntry == nil {
|
if oldEntry != nil {
|
||||||
return
|
oldChunks = oldEntry.GetChunks()
|
||||||
}
|
}
|
||||||
if newEntry == nil {
|
if newEntry != nil {
|
||||||
f.DeleteChunks(oldEntry.GetChunks())
|
newChunks = newEntry.GetChunks()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var toDelete []*filer_pb.FileChunk
|
toDelete, err := MinusChunks(f.MasterClient.GetLookupFileIdFunction(), oldChunks, newChunks)
|
||||||
newChunkIds := make(map[string]bool)
|
|
||||||
newDataChunks, newManifestChunks, err := ResolveChunkManifest(f.MasterClient.GetLookupFileIdFunction(),
|
|
||||||
newEntry.GetChunks(), 0, math.MaxInt64)
|
|
||||||
if err != nil {
|
|
||||||
glog.Errorf("Failed to resolve new entry chunks when delete old entry chunks. new: %s, old: %s",
|
|
||||||
newEntry.GetChunks(), oldEntry.Chunks)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, newChunk := range newDataChunks {
|
|
||||||
newChunkIds[newChunk.GetFileIdString()] = true
|
|
||||||
}
|
|
||||||
for _, newChunk := range newManifestChunks {
|
|
||||||
newChunkIds[newChunk.GetFileIdString()] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
oldDataChunks, oldManifestChunks, err := ResolveChunkManifest(f.MasterClient.GetLookupFileIdFunction(),
|
|
||||||
oldEntry.GetChunks(), 0, math.MaxInt64)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed to resolve old entry chunks when delete old entry chunks. new: %s, old: %s",
|
glog.Errorf("Failed to resolve old entry chunks when delete old entry chunks. new: %s, old: %s",
|
||||||
newEntry.GetChunks(), oldEntry.GetChunks())
|
newChunks, oldChunks)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, oldChunk := range oldDataChunks {
|
|
||||||
if _, found := newChunkIds[oldChunk.GetFileIdString()]; !found {
|
|
||||||
toDelete = append(toDelete, oldChunk)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, oldChunk := range oldManifestChunks {
|
|
||||||
if _, found := newChunkIds[oldChunk.GetFileIdString()]; !found {
|
|
||||||
toDelete = append(toDelete, oldChunk)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
f.DeleteChunksNotRecursive(toDelete)
|
f.DeleteChunksNotRecursive(toDelete)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user