Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

s3: fix --s3-versions flag ignored by cleanup-hidden when GetBucketVersioning fails

Chris40b064993e33
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