mirror of
https://github.com/cooperspencer/gickup.git
synced 2026-10-21 08:18:04 +00:00
fix findings from 372 (#373)
This commit is contained in:
@@ -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)] {
|
||||
|
||||
@@ -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)] {
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user