fix findings from 372 (#373)

This commit is contained in:
Andreas Wachter
2026-04-06 11:34:05 +02:00
committed by GitHub
parent e6999418e2
commit 4bbe669b71
4 changed files with 22 additions and 5 deletions
+2
View File
@@ -308,6 +308,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
for lang, percent := range langs {
if percent > percentage {
language = lang
percentage = percent
}
}
if !languages[strings.ToLower(language)] {
@@ -453,6 +454,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
for lang, percent := range langs {
if percent > percentage {
language = lang
percentage = percent
}
}
if !languages[strings.ToLower(language)] {
+2
View File
@@ -255,6 +255,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
for lang, percent := range *langs {
if percent > percentage {
language = lang
percentage = percent
}
}
if !languages[strings.ToLower(language)] {
@@ -420,6 +421,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
for lang, percent := range *langs {
if percent > percentage {
language = lang
percentage = percent
}
}
if !languages[strings.ToLower(language)] {
+3 -1
View File
@@ -15,6 +15,8 @@ func Send(conf types.HeartbeatConfig) {
log.Error().Str("monitoring", "heartbeat").Msg(err.Error())
continue
}
resp.Body.Close()
if err := resp.Body.Close(); err != nil {
log.Error().Str("monitoring", "heartbeat").Str("url", u).Msg(err.Error())
}
}
}
+15 -4
View File
@@ -2,6 +2,7 @@ package ntfy
import (
"context"
"errors"
"fmt"
"net/http"
"strings"
@@ -14,7 +15,10 @@ func Notify(msg string, config types.PushConfig) error {
payload := strings.NewReader(msg)
req, _ := http.NewRequestWithContext(context.Background(), http.MethodPost, url, payload)
req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, url, payload)
if err != nil {
return err
}
req.Header.Add("Content-Type", "text/plain")
req.Header.Add("Title", "Backup done")
@@ -33,10 +37,17 @@ func Notify(msg string, config types.PushConfig) error {
return err
}
res.Body.Close()
if res.StatusCode != http.StatusOK {
return fmt.Errorf("received status %d from %s", res.StatusCode, config.Url)
statusErr := fmt.Errorf("received status %d from %s", res.StatusCode, config.Url)
if err := res.Body.Close(); err != nil {
return errors.Join(statusErr, err)
}
return statusErr
}
if err := res.Body.Close(); err != nil {
return err
}
return nil