mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
lib/api: Correct logic for errors.jons in support bundle (fixes #5766)
The err check should always be done with != and have the error case first, to follow the pattern and avoid mistakes like these.
This commit is contained in:
parent
997bb5e7e1
commit
41ff4b323e
@ -961,10 +961,10 @@ func (s *service) getSupportBundle(w http.ResponseWriter, r *http.Request) {
|
|||||||
var files []fileEntry
|
var files []fileEntry
|
||||||
|
|
||||||
// Redacted configuration as a JSON
|
// Redacted configuration as a JSON
|
||||||
if jsonConfig, err := json.MarshalIndent(getRedactedConfig(s), "", " "); err == nil {
|
if jsonConfig, err := json.MarshalIndent(getRedactedConfig(s), "", " "); err != nil {
|
||||||
files = append(files, fileEntry{name: "config.json.txt", data: jsonConfig})
|
|
||||||
} else {
|
|
||||||
l.Warnln("Support bundle: failed to create config.json:", err)
|
l.Warnln("Support bundle: failed to create config.json:", err)
|
||||||
|
} else {
|
||||||
|
files = append(files, fileEntry{name: "config.json.txt", data: jsonConfig})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log as a text
|
// Log as a text
|
||||||
@ -977,9 +977,9 @@ func (s *service) getSupportBundle(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Errors as a JSON
|
// Errors as a JSON
|
||||||
if errs := s.guiErrors.Since(time.Time{}); len(errs) > 0 {
|
if errs := s.guiErrors.Since(time.Time{}); len(errs) > 0 {
|
||||||
if jsonError, err := json.MarshalIndent(errs, "", " "); err != nil {
|
if jsonError, err := json.MarshalIndent(errs, "", " "); err != nil {
|
||||||
files = append(files, fileEntry{name: "errors.json.txt", data: jsonError})
|
|
||||||
} else {
|
|
||||||
l.Warnln("Support bundle: failed to create errors.json:", err)
|
l.Warnln("Support bundle: failed to create errors.json:", err)
|
||||||
|
} else {
|
||||||
|
files = append(files, fileEntry{name: "errors.json.txt", data: jsonError})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user