Show unknown filesizes correctly
Cette révision appartient à :
Parent
a6dd34a5de
révision
025cfff297
2 fichiers modifiés avec 9 ajouts et 1 suppressions
|
@ -82,7 +82,7 @@ func (t *Torrents) ToJson() TorrentsJson {
|
||||||
Status: t.Status,
|
Status: t.Status,
|
||||||
Hash: t.Hash,
|
Hash: t.Hash,
|
||||||
Date: time.Unix(t.Date, 0).Format(time.RFC3339),
|
Date: time.Unix(t.Date, 0).Format(time.RFC3339),
|
||||||
Filesize: util.FormatFilesize(t.Filesize),
|
Filesize: util.FormatFilesize2(t.Filesize),
|
||||||
Description: template.HTML(t.Description),
|
Description: template.HTML(t.Description),
|
||||||
Comments: b,
|
Comments: b,
|
||||||
Sub_Category: strconv.Itoa(t.Sub_Category),
|
Sub_Category: strconv.Itoa(t.Sub_Category),
|
||||||
|
|
|
@ -25,3 +25,11 @@ func FormatFilesize(bytes int64) string {
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%.1f %s", value, unit)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Référencer dans un nouveau ticket