From 7373d2eb3ce2508c8ed990ddf35900c741fb973f Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sat, 28 May 2016 14:08:26 +0000 Subject: [PATCH] cmd/syncthing: Fix upgrade of running syncthing from CLI (fixes #3193) GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3198 --- cmd/syncthing/main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 40f773a2..c202eeeb 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -17,8 +17,10 @@ import ( "net" "net/http" _ "net/http/pprof" + "net/url" "os" "os/signal" + "path" "path/filepath" "regexp" "runtime" @@ -476,8 +478,13 @@ func performUpgrade(release upgrade.Release) { func upgradeViaRest() error { cfg, _ := loadConfig() - target := cfg.GUI().URL() - r, _ := http.NewRequest("POST", target+"/rest/system/upgrade", nil) + u, err := url.Parse(cfg.GUI().URL()) + if err != nil { + return err + } + u.Path = path.Join(u.Path, "rest/system/upgrade") + target := u.String() + r, _ := http.NewRequest("POST", target, nil) r.Header.Set("X-API-Key", cfg.GUI().APIKey) tr := &http.Transport{