Skip to content

Commit

Permalink
Filesize changed type to require bigint.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed Feb 27, 2024
1 parent 6af4ac0 commit 20dfdf6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion handler/app/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ func (got DemozooLink) Update(z *zap.SugaredLogger, c echo.Context) error {
return err
}
f.Filename = null.StringFrom(got.Filename)
f.Filesize = null.Int64From(int64(got.FileSize))
f.Filesize = int64(got.FileSize)
f.FileMagicType = null.StringFrom(got.FileType)
f.FileIntegrityStrong = null.StringFrom(got.FileHash)
f.FileZipContent = null.StringFrom(got.Content)
Expand Down
9 changes: 4 additions & 5 deletions handler/app/dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/dustin/go-humanize"
"github.com/h2non/filetype"
"github.com/labstack/echo/v4"
"github.com/volatiletech/null/v8"
"go.uber.org/zap"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
Expand Down Expand Up @@ -110,7 +109,7 @@ func (dir Dirs) About(z *zap.SugaredLogger, c echo.Context, readonly bool) error
// file metadata
data["filename"] = fname
data["filesize"] = aboutByteCount(res.Filesize)
data["filebyte"] = res.Filesize.Int64
data["filebyte"] = res.Filesize
data["lastmodified"] = aboutLM(res)
data["lastmodifiedAgo"] = aboutModAgo(res)
data["checksum"] = strings.TrimSpace(res.FileIntegrityStrong.String)
Expand Down Expand Up @@ -365,11 +364,11 @@ func (dir Dirs) extractor(z *zap.SugaredLogger, c echo.Context, p extract) error
}

// aboutByteCount returns the file size for the file record.
func aboutByteCount(i null.Int64) string {
if !i.Valid || i.Int64 == 0 {
func aboutByteCount(i int64) string {
if i == 0 {
return "(n/a)"
}
return humanize.Bytes(uint64(i.Int64))
return humanize.Bytes(uint64(i))
}

// aboutDesc returns the description for the file record.
Expand Down
2 changes: 1 addition & 1 deletion handler/app/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func DownloadB(i any) template.HTML {
if !val.Valid {
return "(n/a)"
}
s = aboutByteCount(val)
s = aboutByteCount(val.Int64)
default:
return template.HTML(fmt.Sprintf("%sDownloadB: %s", typeErr, reflect.TypeOf(i).String()))
}
Expand Down
10 changes: 5 additions & 5 deletions internal/postgres/models/files.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 20dfdf6

Please sign in to comment.