@@ -335,7 +335,7 @@ func (d *DumpJob) Run(ctx context.Context) (err error) {
335335}
336336}
337337
338- if err := d .cleanupDumpLocation (ctx ,dumpCont .ID );err != nil {
338+ if err := d .cleanupDumpLocation (ctx ,dumpCont .ID , dbList );err != nil {
339339return err
340340}
341341
@@ -406,23 +406,18 @@ func (d *DumpJob) getPassword() string {
406406return pwd
407407}
408408
409- func (d * DumpJob )cleanupDumpLocation (ctx context.Context ,dumpContID string )error {
409+ func (d * DumpJob )cleanupDumpLocation (ctx context.Context ,dumpContID string , dbList map [ string ] DumpDefinition )error {
410410if d .DumpOptions .DumpLocation == "" || d .DumpOptions .Restore .Enabled {
411411return nil
412412}
413413
414- ls ,err := tools .LsContainerDirectory (ctx ,d .dockerClient ,dumpContID ,d .DumpOptions .DumpLocation )
415- if err != nil {
416- return errors .Wrap (err ,"failed to clean up dump location" )
417- }
418-
419- if len (ls )== 0 {
414+ if len (dbList )== 0 {
420415return nil
421416}
422417
423418cleanupCmd := []string {"rm" ,"-rf" }
424419
425- for _ , dbName := range ls {
420+ for dbName := range dbList {
426421cleanupCmd = append (cleanupCmd ,path .Join (d .DumpOptions .DumpLocation ,dbName ))
427422}
428423