From 11372dd54800fc8345e1bb872b01cf05d6382cc6 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 20 Mar 2020 15:38:04 -0700 Subject: [PATCH] refactoring --- weed/operation/chunked_file.go | 10 ++++++++-- weed/server/volume_server_handlers_read.go | 5 +---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/weed/operation/chunked_file.go b/weed/operation/chunked_file.go index 4983245cc..b20c2551e 100644 --- a/weed/operation/chunked_file.go +++ b/weed/operation/chunked_file.go @@ -8,11 +8,10 @@ import ( "io/ioutil" "net/http" "sort" + "sync" "google.golang.org/grpc" - "sync" - "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/util" ) @@ -126,6 +125,13 @@ func readChunkNeedle(fileUrl string, w io.Writer, offset int64) (written int64, return io.Copy(w, resp.Body) } +func NewChunkedFileReader(chunkManifest *ChunkManifest, master string) *ChunkedFileReader { + return &ChunkedFileReader{ + Manifest: chunkManifest, + Master: master, + } +} + func (cf *ChunkedFileReader) Seek(offset int64, whence int) (int64, error) { var err error switch whence { diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.go index 6e603d158..c412062a6 100644 --- a/weed/server/volume_server_handlers_read.go +++ b/weed/server/volume_server_handlers_read.go @@ -187,10 +187,7 @@ func (vs *VolumeServer) tryHandleChunkedFile(n *needle.Needle, fileName string, w.Header().Set("X-File-Store", "chunked") - chunkedFileReader := &operation.ChunkedFileReader{ - Manifest: chunkManifest, - Master: vs.GetMaster(), - } + chunkedFileReader := operation.NewChunkedFileReader(chunkManifest, vs.GetMaster()) defer chunkedFileReader.Close() rs := conditionallyResizeImages(chunkedFileReader, ext, r)