mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
updater: demote "tag empty" to debug log
the stable tag is usually empty because i rarely update it so it'd be nice if this didn't show up so much for normal users. For #313, #329 and more, probably.
This commit is contained in:
@@ -296,6 +296,8 @@ const (
|
||||
FailedGetUpdateTag = "Failed to get latest tag: %v"
|
||||
FailedGetUpdate = "Failed to get update: %v"
|
||||
UpdateTagDetails = "Update/Tag details: %+v"
|
||||
TagEmpty = "tag was empty"
|
||||
TagAtEmpty = "tag at \"%s\" was empty"
|
||||
|
||||
// user-auth.go
|
||||
UserPage = "userpage"
|
||||
|
||||
22
updater.go
22
updater.go
@@ -27,6 +27,18 @@ const (
|
||||
repo = "jfa-go"
|
||||
)
|
||||
|
||||
type TagEmptyError struct {
|
||||
url string
|
||||
}
|
||||
|
||||
func (t *TagEmptyError) Error() string {
|
||||
if t.url != "" {
|
||||
return fmt.Sprintf(lm.TagAtEmpty, t.url)
|
||||
} else {
|
||||
return lm.TagEmpty
|
||||
}
|
||||
}
|
||||
|
||||
var buildTime time.Time = func() time.Time {
|
||||
i, _ := strconv.ParseInt(buildTimeUnix, 10, 64)
|
||||
return time.Unix(i, 0)
|
||||
@@ -213,7 +225,7 @@ func (ud *Updater) GetTag() (Tag, int, error) {
|
||||
var tag Tag
|
||||
err = json.Unmarshal(body, &tag)
|
||||
if tag.Version == "" {
|
||||
err = errors.New("Tag at \"" + url + "\" was empty")
|
||||
err = &TagEmptyError{url: url}
|
||||
}
|
||||
return tag, resp.StatusCode, err
|
||||
}
|
||||
@@ -568,7 +580,13 @@ func (app *appContext) checkForUpdates() {
|
||||
if err != nil && strings.Contains(err.Error(), "strconv.ParseInt") {
|
||||
app.err.Println("No new updates available.")
|
||||
} else if status != -1 { // -1 means updates disabled, we don't need to log it.
|
||||
app.err.Printf(lm.FailedGetUpdateTag, err)
|
||||
// Silence empty tag errors (which occur when there hasn't been any tags in ages it seems)
|
||||
var tagEmpty *TagEmptyError
|
||||
if errors.As(err, &tagEmpty) {
|
||||
app.debug.Printf(lm.FailedGetUpdateTag, err)
|
||||
} else {
|
||||
app.err.Printf(lm.FailedGetUpdateTag, err)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user