diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index d7488122..867b122f 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -121,9 +121,9 @@ jobs: # search package https://pkgs.org/ sudo add-apt-repository universe sudo apt-get -y -qq update - sudo apt-get -y -qq install ffmpeg webp youtube-dl + sudo apt-get -y -qq install ffmpeg webp yt-dlp pip3 install you-get - echo "youtube-dl version $(youtube-dl --version)" + echo "yt-dlp version $(yt-dlp --version)" you-get --version ffmpeg -version 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/docs/changelog.md b/docs/changelog.md index 331a0cc1..2a74081d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fix playback from discord no response - Improve IRC publish +- Improve type conversion ([#628](https://github.com/wabarc/wayback/pull/628)) ## [0.20.1] - 2024-07-02 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)