Correct when S3Store write loop is ended
This commit is contained in:
parent
7f26757a40
commit
d48e4ac577
|
@ -248,9 +248,14 @@ func (store S3Store) WriteChunk(id string, offset int64, src io.Reader) (int64,
|
||||||
|
|
||||||
limitedReader := io.LimitReader(src, store.MaxPartSize)
|
limitedReader := io.LimitReader(src, store.MaxPartSize)
|
||||||
n, err := io.Copy(file, limitedReader)
|
n, err := io.Copy(file, limitedReader)
|
||||||
if err != nil && err != io.EOF {
|
// io.Copy does not return io.EOF, so we not have to handle it differently.
|
||||||
|
if err != nil {
|
||||||
return bytesUploaded, err
|
return bytesUploaded, err
|
||||||
}
|
}
|
||||||
|
// If io.Copy is finished reading, it will always return (0, nil).
|
||||||
|
if n == 0 {
|
||||||
|
return bytesUploaded, nil
|
||||||
|
}
|
||||||
|
|
||||||
if (size - offset) <= store.MinPartSize {
|
if (size - offset) <= store.MinPartSize {
|
||||||
if (size - offset) != n {
|
if (size - offset) != n {
|
||||||
|
@ -274,7 +279,7 @@ func (store S3Store) WriteChunk(id string, offset int64, src io.Reader) (int64,
|
||||||
return bytesUploaded, err
|
return bytesUploaded, err
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += bytesUploaded
|
offset += n
|
||||||
bytesUploaded += n
|
bytesUploaded += n
|
||||||
nextPartNum += 1
|
nextPartNum += 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue