From cb33d8c6a91feb42e25ac1db69fb2946b17fe62b Mon Sep 17 00:00:00 2001 From: Colin Arnott Date: Sun, 3 Oct 2021 20:08:16 +0000 Subject: [PATCH] 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 --- replica.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/replica.go b/replica.go index 0cb9a6a..138851f 100644 --- a/replica.go +++ b/replica.go @@ -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) { // Validate options. if opt.OutputPath == "" { - return fmt.Errorf("output path required") + if r.db.path == "" { + return fmt.Errorf("output path required") + } + opt.OutputPath = r.db.path } else if opt.Generation == "" && opt.Index != math.MaxInt32 { return fmt.Errorf("must specify generation when restoring to index") } else if opt.Index != math.MaxInt32 && !opt.Timestamp.IsZero() {