mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-06 03:42:54 +02:00
Fix attachment size (#787)
Fix `tea releases assets <tag_name>` displayed wrong attachment size. Reviewed-on: https://gitea.com/gitea/tea/pulls/787 Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:

committed by
techknowlogick

parent
9e8c71e13e
commit
449b2e3117
@ -4,9 +4,18 @@
|
||||
package print
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
)
|
||||
|
||||
func formatByteSize(size int64) string {
|
||||
if size < 1024 {
|
||||
return fmt.Sprintf("%d B", size)
|
||||
}
|
||||
return formatSize(size / 1024)
|
||||
}
|
||||
|
||||
// ReleaseAttachmentsList prints a listing of release attachments
|
||||
func ReleaseAttachmentsList(attachments []*gitea.Attachment, output string) {
|
||||
t := tableWithHeader(
|
||||
@ -17,7 +26,7 @@ func ReleaseAttachmentsList(attachments []*gitea.Attachment, output string) {
|
||||
for _, attachment := range attachments {
|
||||
t.addRow(
|
||||
attachment.Name,
|
||||
formatSize(attachment.Size),
|
||||
formatByteSize(attachment.Size),
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user