cmd/syncthing: Fix upgrade of running syncthing from CLI (fixes #3193)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3198
This commit is contained in:
Alexander Graf 2016-05-28 14:08:26 +00:00 committed by Jakob Borg
parent 4453236949
commit 7373d2eb3c
1 changed files with 9 additions and 2 deletions

View File

@ -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{