fix: whitespace at start of path can result in invalid restore target

This commit is contained in:
Gareth George
2025-01-22 19:07:03 -08:00
parent dde9bc6d38
commit 8e625282cb
+3
View File
@@ -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")))
}