Show installed size for binary packages

This commit is contained in:
2025-10-25 13:14:33 +03:00
parent 2db01fb0d4
commit c2d420d854
3 changed files with 63 additions and 39 deletions
+12 -1
View File
@@ -8,6 +8,7 @@ import (
"os"
"path"
"slices"
"strconv"
"strings"
"gopkg.in/yaml.v3"
@@ -280,7 +281,7 @@ func (entry *BPMDatabaseEntry) GetEntryDependants() (dependants []string) {
return dependants
}
func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string) string {
func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string, humanReadableSize bool) string {
ret := make([]string, 0)
appendArray := func(label string, array []string, sort bool) {
if len(array) == 0 {
@@ -346,5 +347,15 @@ func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string) string {
}
ret = append(ret, "Installation Reason: "+installationReasonString)
}
if entry.Info.Type == "binary" {
installedSize := int64(entry.InstalledSize)
var installedSizeStr string
if humanReadableSize {
installedSizeStr = bytesToHumanReadable(installedSize)
} else {
installedSizeStr = strconv.FormatInt(installedSize, 10)
}
ret = append(ret, "Installed size: "+installedSizeStr)
}
return strings.Join(ret, "\n")
}