Browse Source

refactoring

pull/1255/head
Chris Lu 5 years ago
parent
commit
11372dd548
  1. 10
      weed/operation/chunked_file.go
  2. 5
      weed/server/volume_server_handlers_read.go

10
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 {

5
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)

Loading…
Cancel
Save