File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 77 "fmt"
88 "io"
99 "os"
10+ "strings"
1011
1112 "github.com/argoproj/pkg/file"
1213 argos3 "github.com/argoproj/pkg/s3"
@@ -180,7 +181,23 @@ func (s3Driver *ArtifactDriver) Delete(artifact *wfv1.Artifact) error {
180181 if err != nil {
181182 return err
182183 }
183- return s3cli .Delete (artifact .S3 .Bucket , artifact .S3 .Key )
184+
185+ // check suffix instead of s3cli.IsDirectory as it requires another request for file delete (most scenarios)
186+ if ! strings .HasSuffix (artifact .S3 .Key , "/" ) {
187+ return s3cli .Delete (artifact .S3 .Bucket , artifact .S3 .Key )
188+ }
189+
190+ keys , err := s3cli .ListDirectory (artifact .S3 .Bucket , artifact .S3 .Key )
191+ if err != nil {
192+ return fmt .Errorf ("unable to list files in %s: %s" , artifact .S3 .Key , err )
193+ }
194+ for _ , objKey := range keys {
195+ err = s3cli .Delete (artifact .S3 .Bucket , objKey )
196+ if err != nil {
197+ return err
198+ }
199+ }
200+ return nil
184201 })
185202
186203 return err
You can’t perform that action at this time.
0 commit comments