mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-12-21 19:10:11 +08:00
s3: multipart upload miss data if file is chunked in 4MB
fix https://github.com/chrislusf/seaweedfs/issues/2195
This commit is contained in:
@@ -28,19 +28,14 @@ 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) ([]*filer_pb.FileChunk, hash.Hash, int64, error, []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) {
|
||||||
|
|
||||||
md5Hash := md5.New()
|
md5Hash = md5.New()
|
||||||
var partReader = ioutil.NopCloser(io.TeeReader(reader, md5Hash))
|
var partReader = ioutil.NopCloser(io.TeeReader(reader, md5Hash))
|
||||||
|
|
||||||
chunkOffset := int64(0)
|
|
||||||
var smallContent []byte
|
|
||||||
var uploadErr error
|
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var bytesBufferCounter int64
|
var bytesBufferCounter int64
|
||||||
bytesBufferLimitCond := sync.NewCond(new(sync.Mutex))
|
bytesBufferLimitCond := sync.NewCond(new(sync.Mutex))
|
||||||
var fileChunks []*filer_pb.FileChunk
|
|
||||||
var fileChunksLock sync.Mutex
|
var fileChunksLock sync.Mutex
|
||||||
for {
|
for {
|
||||||
|
|
||||||
@@ -67,7 +62,7 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque
|
|||||||
bufPool.Put(bytesBuffer)
|
bufPool.Put(bytesBuffer)
|
||||||
atomic.AddInt64(&bytesBufferCounter, -1)
|
atomic.AddInt64(&bytesBufferCounter, -1)
|
||||||
bytesBufferLimitCond.Signal()
|
bytesBufferLimitCond.Signal()
|
||||||
return nil, md5Hash, 0, err, nil
|
break
|
||||||
}
|
}
|
||||||
if chunkOffset == 0 && !isAppend(r) {
|
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user