|
@ -31,7 +31,6 @@ var bufPool = sync.Pool{ |
|
|
|
|
|
|
|
|
func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Request, reader io.Reader, chunkSize int32, fileName, contentType string, contentLength int64, so *operation.StorageOption) (fileChunks []*filer_pb.FileChunk, md5Hash hash.Hash, chunkOffset int64, uploadErr error, smallContent []byte) { |
|
|
func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Request, reader io.Reader, chunkSize int32, fileName, contentType string, contentLength int64, so *operation.StorageOption) (fileChunks []*filer_pb.FileChunk, md5Hash hash.Hash, chunkOffset int64, uploadErr error, smallContent []byte) { |
|
|
query := r.URL.Query() |
|
|
query := r.URL.Query() |
|
|
isAppend := query.Get("op") == "append" |
|
|
|
|
|
|
|
|
|
|
|
if query.Has("offset") { |
|
|
if query.Has("offset") { |
|
|
offset := query.Get("offset") |
|
|
offset := query.Get("offset") |
|
@ -40,7 +39,7 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque |
|
|
err = fmt.Errorf("invalid 'offset': '%s'", offset) |
|
|
err = fmt.Errorf("invalid 'offset': '%s'", offset) |
|
|
return nil, nil, 0, err, nil |
|
|
return nil, nil, 0, err, nil |
|
|
} |
|
|
} |
|
|
if isAppend && offsetInt > 0 { |
|
|
|
|
|
|
|
|
if isAppend(r) && offsetInt > 0 { |
|
|
err = fmt.Errorf("cannot set offset when op=append") |
|
|
err = fmt.Errorf("cannot set offset when op=append") |
|
|
return nil, nil, 0, err, nil |
|
|
return nil, nil, 0, err, nil |
|
|
} |
|
|
} |
|
@ -81,7 +80,7 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque |
|
|
bytesBufferLimitCond.Signal() |
|
|
bytesBufferLimitCond.Signal() |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
if chunkOffset == 0 && !isAppend { |
|
|
|
|
|
|
|
|
if chunkOffset == 0 && !isAppend(r) { |
|
|
if dataSize < fs.option.SaveToFilerLimit || strings.HasPrefix(r.URL.Path, filer.DirectoryEtcRoot) { |
|
|
if dataSize < fs.option.SaveToFilerLimit || strings.HasPrefix(r.URL.Path, filer.DirectoryEtcRoot) { |
|
|
chunkOffset += dataSize |
|
|
chunkOffset += dataSize |
|
|
smallContent = make([]byte, dataSize) |
|
|
smallContent = make([]byte, dataSize) |
|
|