Skip to content

Commit 1e04969

Browse files
committed
Merge branch 'restore-dump-location' into 'master'
fix: for logicalRestore job, verify that dumpLocation exists in filesystem See merge request postgres-ai/database-lab!801
2 parents 194bab7 + 19298ad commit 1e04969

File tree

1 file changed

+13
-1
lines changed
  • engine/internal/retrieval/engine/postgres/logical

1 file changed

+13
-1
lines changed

engine/internal/retrieval/engine/postgres/logical/restore.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"bytes"
1111
"context"
1212
"fmt"
13+
"io/fs"
1314
"os"
1415
"path"
1516
"path/filepath"
@@ -165,7 +166,18 @@ func (r *RestoreJob) Reload(cfg map[string]interface{}) (err error) {
165166

166167
stat, err := os.Stat(r.RestoreOptions.DumpLocation)
167168
if err != nil {
168-
return errors.Wrap(err, "dumpLocation not found")
169+
if !errors.Is(err, fs.ErrNotExist) {
170+
return errors.Wrap(err, "cannot get stats of dumpLocation")
171+
}
172+
173+
if err := os.MkdirAll(r.RestoreOptions.DumpLocation, 0666); err != nil {
174+
return fmt.Errorf("error creating dumpLocation directory: %w", err)
175+
}
176+
177+
stat, err = os.Stat(r.RestoreOptions.DumpLocation)
178+
if err != nil {
179+
return fmt.Errorf("cannot get stats of dumpLocation: %w", err)
180+
}
169181
}
170182

171183
r.isDumpLocationDir = stat.IsDir()

0 commit comments

Comments
 (0)