From fa3347077a9ac02415f07f849f8fed7b518b08d8 Mon Sep 17 00:00:00 2001 From: Ankit Chawla Date: Mon, 13 Jun 2022 12:35:49 +0530 Subject: [PATCH] Fix for archivepruner to delete files only from subdir (#2456) --- pkg/storagesvc/localstorage.go | 4 ++++ pkg/storagesvc/s3storage.go | 4 ++++ pkg/storagesvc/storagesvc.go | 2 +- pkg/storagesvc/stowClient.go | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/storagesvc/localstorage.go b/pkg/storagesvc/localstorage.go index 1fda9eb6..c1dd4ea0 100644 --- a/pkg/storagesvc/localstorage.go +++ b/pkg/storagesvc/localstorage.go @@ -42,6 +42,10 @@ func (ls localStorage) getUploadFileName() (string, error) { return id.String(), err } +func (ls localStorage) getSubDir() string { + return "" +} + func (ls localStorage) getContainerName() string { return ls.containerName } diff --git a/pkg/storagesvc/s3storage.go b/pkg/storagesvc/s3storage.go index 19eba855..a5692839 100644 --- a/pkg/storagesvc/s3storage.go +++ b/pkg/storagesvc/s3storage.go @@ -49,6 +49,10 @@ func (ss s3Storage) getContainerName() string { return ss.bucketName } +func (ss s3Storage) getSubDir() string { + return ss.subDir +} + func (ss s3Storage) getUploadFileName() (string, error) { id, err := uuid.NewV4() if err != nil { diff --git a/pkg/storagesvc/storagesvc.go b/pkg/storagesvc/storagesvc.go index 8c2f6d65..53e3db64 100644 --- a/pkg/storagesvc/storagesvc.go +++ b/pkg/storagesvc/storagesvc.go @@ -41,7 +41,7 @@ type ( Storage interface { getStorageType() StorageType dial() (stow.Location, error) - // getSubDir() string + getSubDir() string getContainerName() string getUploadFileName() (string, error) } diff --git a/pkg/storagesvc/stowClient.go b/pkg/storagesvc/stowClient.go index d1ea1d3d..be02393d 100644 --- a/pkg/storagesvc/stowClient.go +++ b/pkg/storagesvc/stowClient.go @@ -206,7 +206,7 @@ func (client *StowClient) getItemIDsWithFilter(filterFunc filter, filterFuncPara archiveIDList := make([]string, 0) for { - items, cursor, err = client.container.Items(stow.NoPrefix, cursor, PaginationSize) + items, cursor, err = client.container.Items(client.config.storage.getSubDir(), cursor, PaginationSize) if err != nil { return nil, errors.Wrap(err, "error getting items from container") }