Skip to content

Commit 233aa73

Browse files
committed
STAC-23457 Filter out stackpacks from backup listing
1 parent 5ee7e3a commit 233aa73

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

cmd/settings/list.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ func getBackupListFromLocalBucket(appCtx *app.Context) ([]BackupFileInfo, error)
240240

241241
filteredObjects := s3client.FilterMultipartBackupObjects(result.Contents, isMultiPartArchive)
242242

243+
filteredObjects, err = s3client.FilterByPrefixAndRegex(filteredObjects, "", backupFileNameRegex)
244+
if err != nil {
245+
return nil, fmt.Errorf("failed to filter objects: %w", err)
246+
}
247+
243248
var backups []BackupFileInfo
244249
for _, obj := range filteredObjects {
245250
backups = append(backups, BackupFileInfo{

internal/clients/s3/filter_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,19 @@ func TestFilterByPrefixAndRegex(t *testing.T) { //nolint:funlen // Table-driven
479479
expectedKeys: []string{},
480480
expectError: false,
481481
},
482+
{
483+
name: "excludes stackpacks backups when listing settings local bucket (empty prefix)",
484+
objects: []Object{
485+
{Key: "sts-backup-20240101.sty", Size: 1000, LastModified: now},
486+
{Key: "sts-backup-20240101.sty.stackpacks.zip", Size: 500, LastModified: now},
487+
{Key: "sts-backup-20240102.sty", Size: 2000, LastModified: now},
488+
{Key: "sts-backup-20240102.sty.stackpacks.zip", Size: 300, LastModified: now},
489+
},
490+
prefix: "",
491+
pattern: `^sts-backup-.*\.sty$`,
492+
expectedKeys: []string{"sts-backup-20240101.sty", "sts-backup-20240102.sty"},
493+
expectError: false,
494+
},
482495
{
483496
name: "filters with complex regex pattern",
484497
objects: []Object{

0 commit comments

Comments
 (0)