b2: fix accounting for multpart uploads

This commit is contained in:
Nick Craig-Wood 2023-08-24 17:14:50 +01:00
parent df5d92d709
commit d69cdb79f7

View File

@ -212,6 +212,13 @@ func (up *largeUpload) addSha1(chunkNumber int, sha1 string) {
// WriteChunk will write chunk number with reader bytes, where chunk number >= 0 // WriteChunk will write chunk number with reader bytes, where chunk number >= 0
func (up *largeUpload) WriteChunk(ctx context.Context, chunkNumber int, reader io.ReadSeeker) (size int64, err error) { func (up *largeUpload) WriteChunk(ctx context.Context, chunkNumber int, reader io.ReadSeeker) (size int64, err error) {
// Only account after the checksum reads have been done
if do, ok := reader.(pool.DelayAccountinger); ok {
// To figure out this number, do a transfer and if the accounted size is 0 or a
// multiple of what it should be, increase or decrease this number.
do.DelayAccounting(1)
}
err = up.f.pacer.Call(func() (bool, error) { err = up.f.pacer.Call(func() (bool, error) {
// Discover the size by seeking to the end // Discover the size by seeking to the end
size, err = reader.Seek(0, io.SeekEnd) size, err = reader.Seek(0, io.SeekEnd)