Skip to content

Commit

Permalink
Fix type conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
waybackarchiver committed Jan 1, 2025
1 parent 776eb73 commit 576232f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
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

0 comments on commit 576232f

Please sign in to comment.