From 576232f5f969fec1c00d325d52f9f03f9fe099c0 Mon Sep 17 00:00:00 2001 From: Wayback Archiver <66856220+waybackarchiver@users.noreply.github.com> Date: Wed, 1 Jan 2025 10:47:41 +0000 Subject: [PATCH] Fix type conversion --- config/options.go | 8 +++++++- service/discord/discord.go | 8 +++++++- service/telegram/telegram.go | 8 +++++++- service/utils.go | 9 ++++++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/config/options.go b/config/options.go index 22dd655e..eca1412d 100644 --- a/config/options.go +++ b/config/options.go @@ -8,6 +8,7 @@ import ( "net/url" "os" "path" + "strconv" "strings" "sync" "time" @@ -927,7 +928,12 @@ func (o *Options) WaybackTimeout() time.Duration { // WaybackMaxRetries returns max retries for a wayback request. func (o *Options) WaybackMaxRetries() uint64 { - return uint64(o.waybackMaxRetries) + s := strconv.Itoa(o.waybackMaxRetries) + u, err := strconv.ParseUint(s, 10, 64) + if err != nil { + return 0 + } + return u } // WaybackUserAgent returns User-Agent for a wayback request. diff --git a/service/discord/discord.go b/service/discord/discord.go index 865f6d3c..b1d25027 100644 --- a/service/discord/discord.go +++ b/service/discord/discord.go @@ -205,7 +205,13 @@ func (d *Discord) buttonHandlers() map[string]func(*discord.Session, *discord.In } // Query playback callback data from database - pb, err := d.store.Playback(uint64(id)) + x := strconv.Itoa(id) + u, err := strconv.ParseUint(x, 10, 64) + if err != nil { + logger.Error("parse uint failed: %v", err) + return + } + pb, err := d.store.Playback(u) if err != nil { logger.Error("query playback data failed: %v", err) metrics.IncrementWayback(metrics.ServiceDiscord, metrics.StatusFailure) diff --git a/service/telegram/telegram.go b/service/telegram/telegram.go index 8685c2ec..76faa25e 100644 --- a/service/telegram/telegram.go +++ b/service/telegram/telegram.go @@ -119,7 +119,13 @@ func (t *Telegram) Serve() (err error) { } // Query playback callback data from database - pb, err := t.store.Playback(uint64(id)) + x := strconv.Itoa(id) + u, err := strconv.ParseUint(x, 10, 64) + if err != nil { + logger.Error("parse uint failed: %v", err) + return false + } + pb, err := t.store.Playback(u) if err != nil { logger.Error("query playback data failed: %v", err) metrics.IncrementWayback(metrics.ServiceTelegram, metrics.StatusFailure) diff --git a/service/utils.go b/service/utils.go index 28eb7d2e..32d8f982 100644 --- a/service/utils.go +++ b/service/utils.go @@ -9,6 +9,7 @@ import ( "os" "path" "path/filepath" + "strconv" "strings" "sync" @@ -103,7 +104,13 @@ func filterArtifact(art reduxer.Artifact, upper int64) (paths []string) { } fsize += helper.FileSize(asset.Local) if fsize > upper { - logger.Warn("total file size large than %s, skipped", humanize.Bytes(uint64(upper))) + s := strconv.FormatInt(upper, 10) + u, err := strconv.ParseUint(s, 10, 64) + if err != nil { + logger.Warn("parse uint failed %v", err) + continue + } + logger.Warn("total file size large than %s, skipped", humanize.Bytes(u)) continue } paths = append(paths, asset.Local)