mirror of
https://github.com/rclone/rclone.git
synced 2026-05-24 17:04:50 -04:00
s3: fix --s3-versions flag ignored by cleanup-hidden when GetBucketVersioning fails
When a user has --s3-versions set but lacks the s3:GetBucketVersioning permission, GetBucketVersioning returns an error and isVersioned() caches the result as false. This caused CleanUpHidden (backend cleanup-hidden) to silently exit with "bucket is not versioned so not removing old versions", ignoring the user's explicit --s3-versions flag. Fix this by trusting the explicit --s3-versions flag in purge(), bypassing the GetBucketVersioning check when the user has explicitly declared the bucket is versioned.
This commit is contained in:
@@ -3783,7 +3783,9 @@ func (f *Fs) purge(ctx context.Context, dir string, oldOnly bool) error {
|
||||
if bucket == "" {
|
||||
return errors.New("can't purge from root")
|
||||
}
|
||||
versioned := f.isVersioned(ctx)
|
||||
// If the user explicitly set --s3-versions, trust that the bucket is
|
||||
// versioned even if GetBucketVersioning fails (e.g. missing permission).
|
||||
versioned := f.opt.Versions || f.isVersioned(ctx)
|
||||
if !versioned && oldOnly {
|
||||
fs.Infof(f, "bucket is not versioned so not removing old versions")
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user