Replica.Restore fallback to DB.path

Per the godoc on Replica.Restore and RestoreOptions.OutputPath,
Replica.db.path should be used when RestoreOptions.OutputPath is empty.

Fixes #233
This commit is contained in:
Colin Arnott
2021-10-03 20:08:16 +00:00
committed by Ben Johnson
parent aa2c684c81
commit cb33d8c6a9

View File

@@ -980,7 +980,10 @@ func (r *Replica) CalcRestoreTarget(ctx context.Context, opt RestoreOptions) (ge
func (r *Replica) Restore(ctx context.Context, opt RestoreOptions) (err error) { func (r *Replica) Restore(ctx context.Context, opt RestoreOptions) (err error) {
// Validate options. // Validate options.
if opt.OutputPath == "" { if opt.OutputPath == "" {
if r.db.path == "" {
return fmt.Errorf("output path required") return fmt.Errorf("output path required")
}
opt.OutputPath = r.db.path
} else if opt.Generation == "" && opt.Index != math.MaxInt32 { } else if opt.Generation == "" && opt.Index != math.MaxInt32 {
return fmt.Errorf("must specify generation when restoring to index") return fmt.Errorf("must specify generation when restoring to index")
} else if opt.Index != math.MaxInt32 && !opt.Timestamp.IsZero() { } else if opt.Index != math.MaxInt32 && !opt.Timestamp.IsZero() {