This commit is contained in:
Liang Ding 2022-09-03 23:54:26 +08:00
parent fcfbab3652
commit 9bc71a9f2c
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
15 changed files with 49 additions and 38 deletions

View file

@ -124,6 +124,8 @@ func InstalledTemplates() (ret []*Template) {
continue
}
installPath := filepath.Join(util.DataDir, "templates", dirName)
template := &Template{}
template.Installed = true
template.Name = templateConf["name"].(string)
@ -134,10 +136,11 @@ func InstalledTemplates() (ret []*Template) {
template.PreviewURL = "/templates/" + dirName + "/preview.png"
template.PreviewURLThumb = "/templates/" + dirName + "/preview.png"
template.Updated = templateDir.ModTime().Format("2006-01-02 15:04:05")
template.Size = templateDir.Size()
template.HSize = humanize.Bytes(uint64(template.Size))
template.HUpdated = formatUpdated(template.Updated)
readme, readErr := os.ReadFile(filepath.Join(util.DataDir, "templates", dirName, "README.md"))
installSize, _ := util.SizeOfDirectory(installPath)
template.InstallSize = installSize
template.HInstallSize = humanize.Bytes(uint64(installSize))
readme, readErr := os.ReadFile(filepath.Join(installPath, "README.md"))
if nil != readErr {
logging.LogWarnf("read install template README.md failed: %s", readErr)
continue