diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-06-20 08:00:25 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-06-20 08:00:25 -0700 |
| commit | ca3516ac6d9cc266b4953d96360c0c733e7244a3 (patch) | |
| tree | fe45213c1bb6b6300de23d3bc000c26bb43558b8 /weed/server | |
| parent | e912fd15e32179ca532c23011ce7bc9186586ba4 (diff) | |
| download | seaweedfs-ca3516ac6d9cc266b4953d96360c0c733e7244a3.tar.xz seaweedfs-ca3516ac6d9cc266b4953d96360c0c733e7244a3.zip | |
adjust protoc
Diffstat (limited to 'weed/server')
| -rw-r--r-- | weed/server/volume_grpc_file.go | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/weed/server/volume_grpc_file.go b/weed/server/volume_grpc_file.go deleted file mode 100644 index 61fcaeb00..000000000 --- a/weed/server/volume_grpc_file.go +++ /dev/null @@ -1,130 +0,0 @@ -package weed_server - -import ( - "encoding/json" - "net/http" - "strings" - - "github.com/chrislusf/seaweedfs/weed/glog" - "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" - "github.com/chrislusf/seaweedfs/weed/storage/needle" - "github.com/chrislusf/seaweedfs/weed/util" -) - -// Deprecated -func (vs *VolumeServer) FileGet(req *volume_server_pb.FileGetRequest, stream volume_server_pb.VolumeServer_FileGetServer) error { - - headResponse := &volume_server_pb.FileGetResponse{} - n := new(needle.Needle) - - commaIndex := strings.LastIndex(req.FileId, ",") - vid := req.FileId[:commaIndex] - fid := req.FileId[commaIndex+1:] - - volumeId, err := needle.NewVolumeId(vid) - if err != nil { - headResponse.ErrorCode = http.StatusBadRequest - return stream.Send(headResponse) - } - err = n.ParsePath(fid) - if err != nil { - headResponse.ErrorCode = http.StatusBadRequest - return stream.Send(headResponse) - } - - hasVolume := vs.store.HasVolume(volumeId) - _, hasEcVolume := vs.store.FindEcVolume(volumeId) - - if !hasVolume && !hasEcVolume { - headResponse.ErrorCode = http.StatusMovedPermanently - return stream.Send(headResponse) - } - - cookie := n.Cookie - var count int - if hasVolume { - count, err = vs.store.ReadVolumeNeedle(volumeId, n) - } else if hasEcVolume { - count, err = vs.store.ReadEcShardNeedle(volumeId, n) - } - - if err != nil || count < 0 { - headResponse.ErrorCode = http.StatusNotFound - return stream.Send(headResponse) - } - if n.Cookie != cookie { - headResponse.ErrorCode = http.StatusNotFound - return stream.Send(headResponse) - } - - if n.LastModified != 0 { - headResponse.LastModified = n.LastModified - } - - headResponse.Etag = n.Etag() - - if n.HasPairs() { - pairMap := make(map[string]string) - err = json.Unmarshal(n.Pairs, &pairMap) - if err != nil { - glog.V(0).Infoln("Unmarshal pairs error:", err) - } - headResponse.Headers = pairMap - } - - /* - // skip this, no redirection - if vs.tryHandleChunkedFile(n, filename, w, r) { - return - } - */ - - if n.NameSize > 0 { - headResponse.Filename = string(n.Name) - } - mtype := "" - if n.MimeSize > 0 { - mt := string(n.Mime) - if !strings.HasPrefix(mt, "application/octet-stream") { - mtype = mt - } - } - headResponse.ContentType = mtype - - headResponse.IsGzipped = n.IsCompressed() - - if n.IsCompressed() && req.AcceptGzip { - if n.Data, err = util.UnCompressData(n.Data); err != nil { - glog.V(0).Infof("ungzip %s error: %v", req.FileId, err) - } - } - - headResponse.ContentLength = uint32(len(n.Data)) - bytesToRead := len(n.Data) - bytesRead := 0 - - t := headResponse - - for bytesRead < bytesToRead { - - stopIndex := bytesRead + BufferSizeLimit - if stopIndex > bytesToRead { - stopIndex = bytesToRead - } - - if t == nil { - t = &volume_server_pb.FileGetResponse{} - } - t.Data = n.Data[bytesRead:stopIndex] - - err = stream.Send(t) - t = nil - if err != nil { - return err - } - - bytesRead = stopIndex - } - - return nil -} |
