filer read empty file may cause OOM in some cases

fix https://github.com/chrislusf/seaweedfs/issues/2641
This commit is contained in:
chrislu
2022-02-07 23:08:54 -08:00
parent b1cff07ab0
commit 85c1615b43
5 changed files with 10 additions and 16 deletions

View File

@@ -75,12 +75,12 @@ func (fc *FilerConf) loadFromFiler(filer *Filer) (err error) {
return fc.LoadFromBytes(entry.Content)
}
return fc.loadFromChunks(filer, entry.Content, entry.Chunks)
return fc.loadFromChunks(filer, entry.Content, entry.Chunks, entry.Size())
}
func (fc *FilerConf) loadFromChunks(filer *Filer, content []byte, chunks []*filer_pb.FileChunk) (err error) {
func (fc *FilerConf) loadFromChunks(filer *Filer, content []byte, chunks []*filer_pb.FileChunk, size uint64) (err error) {
if len(content) == 0 {
content, err = filer.readEntry(chunks)
content, err = filer.readEntry(chunks, size)
if err != nil {
glog.Errorf("read filer conf content: %v", err)
return