Skip to content

Commit

Permalink
check the size of a file
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro committed Jan 15, 2024
1 parent 93cb740 commit debad53
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ func doCopyMultiple(src, dst object.ObjectStorage, key string, size int64, uploa
if partSize == 0 {
partSize = defaultPartSize
}
limits := dst.Limits()
if size > int64(limits.MaxPartSize)*int64(limits.MaxPartCount) {
return fmt.Errorf("object size %d is too large to copy", size)
}
if size > partSize*int64(upload.MaxCount) {
partSize = size / int64(upload.MaxCount)
partSize = ((partSize-1)>>20 + 1) << 20 // align to MB
Expand Down

0 comments on commit debad53

Please sign in to comment.