Skip to content

Commit 5af1edd

Browse files
authored
Merge pull request #1456 from swordqiu/hotfix/qj-miss-multipart-errors
fix: miss out errors of multipart objects
2 parents 6fef6a5 + 0188505 commit 5af1edd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/cloudprovider/objectstore.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,15 +544,15 @@ type uploadPartOfMultipartJob struct {
544544
offset int64
545545
debug bool
546546
etags []string
547-
errs []error
547+
errs *[]error
548548
}
549549

550550
func uploadPartOfMultipartWorker(wg *sync.WaitGroup, queue chan uploadPartOfMultipartJob) {
551551
defer wg.Done()
552552
for job := range queue {
553553
tag, err := uploadPartOfMultipart(job.ctx, job.bucket, job.key, job.input, job.sizeBytes, job.uploadId, job.partIndex, job.partSize, job.offset, job.debug)
554554
if err != nil {
555-
job.errs = append(job.errs, err)
555+
*job.errs = append(*job.errs, err)
556556
} else {
557557
job.etags[job.partIndex] = tag
558558
}
@@ -640,7 +640,7 @@ func UploadObjectParallel(ctx context.Context, bucket ICloudBucket, key string,
640640
offset: offset,
641641
debug: debug,
642642
etags: etags,
643-
errs: errs,
643+
errs: &errs,
644644
}
645645
queue <- job
646646
}
@@ -721,15 +721,15 @@ type copyPartOfMultipartJob struct {
721721
partIndex int
722722
debug bool
723723
etags []string
724-
errs []error
724+
errs *[]error
725725
}
726726

727727
func copyPartOfMultipartWorker(wg *sync.WaitGroup, queue chan copyPartOfMultipartJob) {
728728
defer wg.Done()
729729
for job := range queue {
730730
tag, err := copyPartOfMultipart(job.ctx, job.dstBucket, job.dstKey, job.srcBucket, job.srcKey, job.rangeOpt, job.sizeBytes, job.uploadId, job.partIndex, job.debug)
731731
if err != nil {
732-
job.errs = append(job.errs, err)
732+
*job.errs = append(*job.errs, err)
733733
} else {
734734
job.etags[job.partIndex] = tag
735735
}
@@ -844,7 +844,7 @@ func CopyObjectParallel(ctx context.Context, blocksz int64, dstBucket ICloudBuck
844844
partIndex: partIndex,
845845
debug: debug,
846846
etags: etags,
847-
errs: errs,
847+
errs: &errs,
848848
}
849849
queue <- job
850850
}
@@ -1052,7 +1052,7 @@ func (ow *sOffsetWriter) Write(p []byte) (int, error) {
10521052
}
10531053

10541054
func calculateRateMbps(sizeBytes int64, duration time.Duration) float64 {
1055-
return float64(sizeBytes*8) / (float64(duration) / float64(time.Second)) / 1000 / 1000
1055+
return float64(sizeBytes*8/1000/1000) / (float64(duration) / float64(time.Second))
10561056
}
10571057

10581058
type downloadPartOfMultipartJob struct {
@@ -1064,7 +1064,7 @@ type downloadPartOfMultipartJob struct {
10641064
partIndex int
10651065
debug bool
10661066
segSizes []int64
1067-
errs []error
1067+
errs *[]error
10681068
callback func(saved int64, written int64)
10691069
}
10701070

@@ -1073,7 +1073,7 @@ func downloadPartOfMultipartWorker(wg *sync.WaitGroup, queue chan downloadPartOf
10731073
for job := range queue {
10741074
sz, err := downloadPartOfMultipart(job.ctx, job.bucket, job.key, job.rangeOpt, job.output, job.partIndex, job.debug, job.callback)
10751075
if err != nil {
1076-
job.errs = append(job.errs, err)
1076+
*job.errs = append(*job.errs, err)
10771077
} else {
10781078
job.segSizes[job.partIndex] = sz
10791079
}
@@ -1237,7 +1237,7 @@ func DownloadObjectParallelWithProgress(ctx context.Context, bucket ICloudBucket
12371237
partIndex: partIndex,
12381238
debug: debug,
12391239
segSizes: segSizes,
1240-
errs: errs,
1240+
errs: &errs,
12411241
callback: progressCallback,
12421242
}
12431243
queue <- job

0 commit comments

Comments
 (0)