From b5f28da452d2ab06063f28abc331471427b0a311 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Fri, 21 Nov 2025 17:22:49 +0000 Subject: [PATCH] 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. --- logmessages/logmessages.go | 2 ++ updater.go | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/logmessages/logmessages.go b/logmessages/logmessages.go index 8d2c730..38da362 100644 --- a/logmessages/logmessages.go +++ b/logmessages/logmessages.go @@ -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" diff --git a/updater.go b/updater.go index c9836e8..4126f26 100644 --- a/updater.go +++ b/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 }