mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 09:05:59 +08:00
s3: validate CopyCutoff size before copy
Signed-off-by: hoyho <luohaihao@gmail.com>
This commit is contained in:
parent
bf494d48d6
commit
a24aeba495
|
@ -3022,6 +3022,14 @@ func (f *Fs) setUploadChunkSize(cs fs.SizeSuffix) (old fs.SizeSuffix, err error)
|
|||
return
|
||||
}
|
||||
|
||||
func checkCopyCutoff(cs fs.SizeSuffix) error {
|
||||
minCopySize := fs.SizeSuffixBase
|
||||
if cs < minCopySize {
|
||||
return fmt.Errorf("value is too small (%v is less than %v)", cs, minCopySize)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkUploadCutoff(cs fs.SizeSuffix) error {
|
||||
if cs > maxUploadCutoff {
|
||||
return fmt.Errorf("%s is greater than %s", cs, maxUploadCutoff)
|
||||
|
@ -3322,6 +3330,10 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("s3: upload cutoff: %w", err)
|
||||
}
|
||||
err = checkCopyCutoff(opt.CopyCutoff)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("s3: --s3-copy-cutoff: %w", err)
|
||||
}
|
||||
if opt.Versions && opt.VersionAt.IsSet() {
|
||||
return nil, errors.New("s3: can't use --s3-versions and --s3-version-at at the same time")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user