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

@@ -2,12 +2,10 @@ package shell
import (
"fmt"
"io"
"math"
"github.com/chrislusf/seaweedfs/weed/filer"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util"
"io"
)
func init() {
@@ -57,7 +55,7 @@ func (c *commandFsCat) Do(args []string, commandEnv *CommandEnv, writer io.Write
return err
}
return filer.StreamContent(commandEnv.MasterClient, writer, respLookupEntry.Entry.Chunks, 0, math.MaxInt64)
return filer.StreamContent(commandEnv.MasterClient, writer, respLookupEntry.Entry.Chunks, 0, int64(filer.FileSize(respLookupEntry.Entry)))
})