This commit is contained in:
Daniel 2024-04-28 22:48:05 +08:00
parent 479370b9f5
commit bc22aa0c35
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
7 changed files with 66 additions and 21 deletions

View file

@ -89,6 +89,9 @@ func Icons() (icons []*Icon) {
icon.OpenIssues = repo.OpenIssues
icon.Size = repo.Size
icon.HSize = humanize.BytesCustomCeil(uint64(icon.Size), 2)
icon.InstallSize = repo.InstallSize
icon.HInstallSize = humanize.BytesCustomCeil(uint64(icon.InstallSize), 2)
packageInstallSizeCache.SetDefault(icon.RepoURL, icon.InstallSize)
icon.HUpdated = formatUpdated(icon.Updated)
pkg := bazaarIndex[strings.Split(repoURL, "@")[0]]
if nil != pkg {
@ -156,9 +159,14 @@ func InstalledIcons() (ret []*Icon) {
continue
}
icon.HInstallDate = info.ModTime().Format("2006-01-02")
installSize, _ := util.SizeOfDirectory(installPath)
icon.InstallSize = installSize
icon.HInstallSize = humanize.BytesCustomCeil(uint64(installSize), 2)
if installSize, ok := packageInstallSizeCache.Get(icon.RepoURL); ok {
icon.InstallSize = installSize.(int64)
} else {
is, _ := util.SizeOfDirectory(installPath)
icon.InstallSize = is
packageInstallSizeCache.SetDefault(icon.RepoURL, is)
}
icon.HInstallSize = humanize.BytesCustomCeil(uint64(icon.InstallSize), 2)
readmeFilename := getPreferredReadme(icon.Readme)
readme, readErr := os.ReadFile(filepath.Join(installPath, readmeFilename))
if nil != readErr {