diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 47cf7702f..9f60f70ce 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -403,9 +403,11 @@ func upgradeViaRest() error { if err != nil { return err } + + defer resp.Body.Close() + if resp.StatusCode != 200 { bs, err := io.ReadAll(resp.Body) - defer resp.Body.Close() if err != nil { return err }