forked from TrueCloudLab/rclone
s3: validate CopyCutoff size before copy
Signed-off-by: hoyho <luohaihao@gmail.com>
This commit is contained in:
parent
bf494d48d6
commit
a24aeba495
1 changed files with 12 additions and 0 deletions
|
@ -3022,6 +3022,14 @@ func (f *Fs) setUploadChunkSize(cs fs.SizeSuffix) (old fs.SizeSuffix, err error)
|
||||||
return
|
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 {
|
func checkUploadCutoff(cs fs.SizeSuffix) error {
|
||||||
if cs > maxUploadCutoff {
|
if cs > maxUploadCutoff {
|
||||||
return fmt.Errorf("%s is greater than %s", 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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("s3: upload cutoff: %w", err)
|
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() {
|
if opt.Versions && opt.VersionAt.IsSet() {
|
||||||
return nil, errors.New("s3: can't use --s3-versions and --s3-version-at at the same time")
|
return nil, errors.New("s3: can't use --s3-versions and --s3-version-at at the same time")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue