From 8e625282cbe243a9ec1cddc73cc19cb0f0703c86 Mon Sep 17 00:00:00 2001 From: Gareth George Date: Wed, 22 Jan 2025 19:07:03 -0800 Subject: [PATCH] fix: whitespace at start of path can result in invalid restore target --- internal/api/backresthandler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/api/backresthandler.go b/internal/api/backresthandler.go index d3c74315..0d8cd726 100644 --- a/internal/api/backresthandler.go +++ b/internal/api/backresthandler.go @@ -531,6 +531,9 @@ func (s BackrestHandler) DoRepoTask(ctx context.Context, req *connect.Request[v1 } func (s *BackrestHandler) Restore(ctx context.Context, req *connect.Request[v1.RestoreSnapshotRequest]) (*connect.Response[emptypb.Empty], error) { + req.Msg.Target = strings.TrimSpace(req.Msg.Target) + req.Msg.Path = strings.TrimSpace(req.Msg.Path) + if req.Msg.Target == "" { req.Msg.Target = path.Join(os.Getenv("HOME"), "Downloads", fmt.Sprintf("restic-restore-%v", time.Now().Format("2006-01-02T15-04-05"))) }