Skip to content

Commit 12886dd

Browse files
committed
Merge branch '313-delete-conflict-dump-files' into 'master'
feat: clean up only files or directories that are specified to be restored (#313) Closes #313 See merge request postgres-ai/database-lab!410
2 parents e09f72b + b78397d commit 12886dd

File tree

1 file changed

+4
-9
lines changed
  • internal/retrieval/engine/postgres/logical

1 file changed

+4
-9
lines changed

Diff for: internal/retrieval/engine/postgres/logical/dump.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -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 {
339339
return err
340340
}
341341

@@ -406,23 +406,18 @@ func (d *DumpJob) getPassword() string {
406406
return 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 {
410410
if d.DumpOptions.DumpLocation == "" || d.DumpOptions.Restore.Enabled {
411411
return 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 {
420415
return nil
421416
}
422417

423418
cleanupCmd := []string{"rm", "-rf"}
424419

425-
for _, dbName := range ls {
420+
for dbName := range dbList {
426421
cleanupCmd = append(cleanupCmd, path.Join(d.DumpOptions.DumpLocation, dbName))
427422
}
428423

0 commit comments

Comments
 (0)