From 40b064993e332da2277b0e9ba9768fc7defc056e Mon Sep 17 00:00:00 2001 From: Chris <238498929+chris081519-crypto@users.noreply.github.com> Date: Fri, 3 Apr 2026 17:12:42 +0200 Subject: [PATCH] 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. --- backend/s3/s3.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index ee40cfeec..6c799ec18 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -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