Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type conversion #628

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/url"
"os"
"path"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion service/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion service/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion service/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path"
"path/filepath"
"strconv"
"strings"
"sync"

Expand Down Expand Up @@ -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)
Expand Down
Loading