From bfc3c11fdc2f890fa527df26c2b5f581f2ec9c53 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 25 Dec 2022 00:30:06 -0800 Subject: [PATCH] remove useless logic --- weed/mount/filehandle.go | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/weed/mount/filehandle.go b/weed/mount/filehandle.go index b6ec3d2da..9f1a863d1 100644 --- a/weed/mount/filehandle.go +++ b/weed/mount/filehandle.go @@ -78,30 +78,7 @@ func (fh *FileHandle) AddChunks(chunks []*filer_pb.FileChunk) { return } - // find the earliest incoming chunk - newChunks := chunks - earliestChunk := newChunks[0] - for i := 1; i < len(newChunks); i++ { - if lessThan(earliestChunk, newChunks[i]) { - earliestChunk = newChunks[i] - } - } - - // pick out-of-order chunks from existing chunks - for _, chunk := range fh.entry.GetChunks() { - if lessThan(earliestChunk, chunk) { - chunks = append(chunks, chunk) - } - } - - // sort incoming chunks - slices.SortFunc(chunks, func(a, b *filer_pb.FileChunk) bool { - return lessThan(a, b) - }) - - glog.V(4).Infof("%s existing %d chunks adds %d more", fh.FullPath(), len(fh.entry.GetChunks()), len(chunks)) - - fh.entry.AppendChunks(newChunks) + fh.entry.AppendChunks(chunks) fh.entryViewCache = nil } @@ -115,11 +92,5 @@ func (fh *FileHandle) CloseReader() { func (fh *FileHandle) Release() { fh.dirtyPages.Destroy() fh.CloseReader() -} - -func lessThan(a, b *filer_pb.FileChunk) bool { - if a.ModifiedTsNs == b.ModifiedTsNs { - return a.Fid.FileKey < b.Fid.FileKey } - return a.ModifiedTsNs < b.ModifiedTsNs }