Skip to content

Commit 52736a4

Browse files
authored
Merge pull request #1732 from swordqiu/automated-cherry-pick-of-#1730-upstream-release-4.0.2
Automated cherry pick of #1730: fix: s3 progress percentage
2 parents 5ae31a4 + 0516685 commit 52736a4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/cloudprovider/objectstore.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,14 +1128,14 @@ func newDownloadProgresser(totalSize int64, callback func(progress float64, prog
11281128
func (p *sDownloadProgresser) Progress(_ int64, written int64) {
11291129
p.progress += written
11301130
duration := time.Since(p.startTime)
1131-
progress := float64(p.progress) / float64(p.totalSize)
1131+
progress := float64(p.progress*100) / float64(p.totalSize)
11321132
progressMbps := calculateRateMbps(p.progress, duration)
11331133
if p.callback != nil {
11341134
p.callback(progress, progressMbps, p.totalSize/1000/1000)
11351135
}
11361136
if time.Since(p.reportTime) > time.Second*5 {
11371137
p.reportTime = time.Now()
1138-
log.Infof("Download progress: %d/%d, %f%%, %fMbps", p.progress, p.totalSize, progress*100, progressMbps)
1138+
log.Infof("Download progress: %d/%d, %f%%, %fMbps", p.progress, p.totalSize, progress, progressMbps)
11391139
}
11401140
}
11411141

@@ -1146,6 +1146,9 @@ func (p *sDownloadProgresser) Summary() {
11461146
}
11471147

11481148
func DownloadObjectParallelWithProgress(ctx context.Context, bucket ICloudBucket, key string, rangeOpt *SGetObjectRange, output io.WriterAt, outputOffset int64, blocksz int64, debug bool, parallel int, callback func(progress float64, progressMbps float64, totalSizeMb int64)) (int64, error) {
1149+
if debug {
1150+
log.Debugf("DownloadObjectParallelWithProgress bucket: %s key: %s offset: %d blocksz: %d parallel: %d", bucket.GetName(), key, outputOffset, blocksz, parallel)
1151+
}
11491152
obj, err := GetIObject(bucket, key)
11501153
if err != nil {
11511154
return 0, errors.Wrap(err, "GetIObject")

0 commit comments

Comments
 (0)