Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Show unknown filesizes correctly

Cette révision appartient à :
sfan5 2017-05-07 13:51:59 +02:00
Parent a6dd34a5de
révision 025cfff297
2 fichiers modifiés avec 9 ajouts et 1 suppressions

Voir le fichier

@ -82,7 +82,7 @@ func (t *Torrents) ToJson() TorrentsJson {
Status: t.Status,
Hash: t.Hash,
Date: time.Unix(t.Date, 0).Format(time.RFC3339),
Filesize: util.FormatFilesize(t.Filesize),
Filesize: util.FormatFilesize2(t.Filesize),
Description: template.HTML(t.Description),
Comments: b,
Sub_Category: strconv.Itoa(t.Sub_Category),

Voir le fichier

@ -25,3 +25,11 @@ func FormatFilesize(bytes int64) string {
}
return fmt.Sprintf("%.1f %s", value, unit)
}
func FormatFilesize2(bytes int64) string {
if bytes == 0 { // this is what gorm returns for NULL
return "Unknown"
} else {
return FormatFilesize(bytes)
}
}