mount: skip local chunk cache if opened write only

This commit is contained in:
Chris Lu
2021-05-06 03:31:40 -07:00
parent c899bdf063
commit 38f411219a
6 changed files with 16 additions and 8 deletions

View File

@@ -13,7 +13,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/util"
)
func (wfs *WFS) saveDataAsChunk(fullPath util.FullPath) filer.SaveDataAsChunkFunctionType {
func (wfs *WFS) saveDataAsChunk(fullPath util.FullPath, writeOnly bool) filer.SaveDataAsChunkFunctionType {
return func(reader io.Reader, filename string, offset int64) (chunk *filer_pb.FileChunk, collection, replication string, err error) {
var fileId, host string
@@ -67,7 +67,9 @@ func (wfs *WFS) saveDataAsChunk(fullPath util.FullPath) filer.SaveDataAsChunkFun
return nil, "", "", fmt.Errorf("upload result: %v", uploadResult.Error)
}
wfs.chunkCache.SetChunk(fileId, data)
if !writeOnly {
wfs.chunkCache.SetChunk(fileId, data)
}
chunk = uploadResult.ToPbFileChunk(fileId, offset)
return chunk, collection, replication, nil