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

@ -95,6 +95,7 @@
"netImg2LocalAsset": "Convert network images to local images", "netImg2LocalAsset": "Convert network images to local images",
"releaseDate": "Release Date", "releaseDate": "Release Date",
"pkgSize": "Package size", "pkgSize": "Package size",
"installSize": "Install Size",
"optimizeTypography": "Optimize typography", "optimizeTypography": "Optimize typography",
"dragPosition": "Drag image to reposition", "dragPosition": "Drag image to reposition",
"exportPDF0": "Page Size", "exportPDF0": "Page Size",

View file

@ -95,6 +95,7 @@
"netImg2LocalAsset": "Convertir imágenes de red en imágenes locales", "netImg2LocalAsset": "Convertir imágenes de red en imágenes locales",
"releaseDate": "Fecha de lanzamiento", "releaseDate": "Fecha de lanzamiento",
"pkgSize": "Tamaño del paquete", "pkgSize": "Tamaño del paquete",
"installSize": "Tamaño de instalación",
"optimizeTypography": "Insertar un espacio entre el chino y el occidental", "optimizeTypography": "Insertar un espacio entre el chino y el occidental",
"dragPosition": "Arrastrar imagen para reposicionarla", "dragPosition": "Arrastrar imagen para reposicionarla",
"exportPDF0": "Tamaño de la página", "exportPDF0": "Tamaño de la página",

View file

@ -95,6 +95,7 @@
"netImg2LocalAsset": "Convertir des images réseau en images locales", "netImg2LocalAsset": "Convertir des images réseau en images locales",
"releaseDate": "Date de sortie", "releaseDate": "Date de sortie",
"pkgSize": "Taille du package", "pkgSize": "Taille du package",
"installSize": "Taille d'installation",
"optimizeTypography": "Optimiser la typographie", "optimizeTypography": "Optimiser la typographie",
"dragPosition": "Faites glisser l'image pour la repositionner", "dragPosition": "Faites glisser l'image pour la repositionner",
"exportPDF0": "Taille de la page", "exportPDF0": "Taille de la page",

View file

@ -95,6 +95,7 @@
"netImg2LocalAsset": "網絡圖片轉換為本地圖片", "netImg2LocalAsset": "網絡圖片轉換為本地圖片",
"releaseDate": "發布日期", "releaseDate": "發布日期",
"pkgSize": "包大小", "pkgSize": "包大小",
"installSize": "安裝大小",
"optimizeTypography": "優化排版", "optimizeTypography": "優化排版",
"dragPosition": "拖動圖像重新定位", "dragPosition": "拖動圖像重新定位",
"exportPDF0": "頁面大小", "exportPDF0": "頁面大小",

View file

@ -95,6 +95,7 @@
"netImg2LocalAsset": "网络图片转换为本地图片", "netImg2LocalAsset": "网络图片转换为本地图片",
"releaseDate": "发布日期", "releaseDate": "发布日期",
"pkgSize": "包大小", "pkgSize": "包大小",
"installSize": "安装大小",
"optimizeTypography": "优化排版", "optimizeTypography": "优化排版",
"dragPosition": "上下拖动图片以调整位置", "dragPosition": "上下拖动图片以调整位置",
"exportPDF0": "页面大小", "exportPDF0": "页面大小",

View file

@ -266,7 +266,7 @@ export const bazaar = {
<div class="fn__hr"></div> <div class="fn__hr"></div>
<div class="ft__on-surface ft__smaller" style="line-height: 20px;">${window.siyuan.languages.releaseDate}<br>${data.hUpdated}</div> <div class="ft__on-surface ft__smaller" style="line-height: 20px;">${window.siyuan.languages.releaseDate}<br>${data.hUpdated}</div>
<div class="fn__hr"></div> <div class="fn__hr"></div>
<div class="ft__on-surface ft__smaller" style="line-height: 20px;">${window.siyuan.languages.pkgSize}<br>${data.hSize}</div> <div class="ft__on-surface ft__smaller" style="line-height: 20px;">${isDownloaded ? window.siyuan.languages.installSize : window.siyuan.languages.pkgSize}<br>${isDownloaded ? data.hInstallSize : data.hSize}</div>
<div class="fn__hr--b"></div> <div class="fn__hr--b"></div>
<div class="fn__hr--b"></div> <div class="fn__hr--b"></div>
<div class="${(data.installed || isDownloaded) ? "fn__none" : ""}" data-type="${data.modes?.toString()}"> <div class="${(data.installed || isDownloaded) ? "fn__none" : ""}" data-type="${data.modes?.toString()}">

View file

@ -495,5 +495,6 @@ declare interface IBazaarItem {
version: string version: string
modes: string[] modes: string[]
hSize: string hSize: string
hInstallSize: string
hUpdated: string hUpdated: string
} }

View file

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

View file

@ -58,6 +58,8 @@ type Package struct {
OpenIssues int `json:"openIssues"` OpenIssues int `json:"openIssues"`
Size int64 `json:"size"` Size int64 `json:"size"`
HSize string `json:"hSize"` HSize string `json:"hSize"`
InstallSize int64 `json:"installSize"`
HInstallSize string `json:"hInstallSize"`
HUpdated string `json:"hUpdated"` HUpdated string `json:"hUpdated"`
Downloads int `json:"downloads"` Downloads int `json:"downloads"`
} }

View file

@ -124,6 +124,8 @@ func InstalledTemplates() (ret []*Template) {
continue continue
} }
installPath := filepath.Join(util.DataDir, "templates", dirName)
template := &Template{} template := &Template{}
template.Installed = true template.Installed = true
template.Name = templateConf["name"].(string) template.Name = templateConf["name"].(string)
@ -134,10 +136,11 @@ func InstalledTemplates() (ret []*Template) {
template.PreviewURL = "/templates/" + dirName + "/preview.png" template.PreviewURL = "/templates/" + dirName + "/preview.png"
template.PreviewURLThumb = "/templates/" + dirName + "/preview.png" template.PreviewURLThumb = "/templates/" + dirName + "/preview.png"
template.Updated = templateDir.ModTime().Format("2006-01-02 15:04:05") 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) 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 { if nil != readErr {
logging.LogWarnf("read install template README.md failed: %s", readErr) logging.LogWarnf("read install template README.md failed: %s", readErr)
continue continue

View file

@ -126,6 +126,8 @@ func InstalledThemes() (ret []*Theme) {
continue continue
} }
installPath := filepath.Join(util.ThemesPath, dirName)
theme := &Theme{} theme := &Theme{}
theme.Installed = true theme.Installed = true
theme.Name = themeConf["name"].(string) theme.Name = themeConf["name"].(string)
@ -137,10 +139,11 @@ func InstalledThemes() (ret []*Theme) {
theme.PreviewURL = "/appearance/themes/" + dirName + "/preview.png" theme.PreviewURL = "/appearance/themes/" + dirName + "/preview.png"
theme.PreviewURLThumb = "/appearance/themes/" + dirName + "/preview.png" theme.PreviewURLThumb = "/appearance/themes/" + dirName + "/preview.png"
theme.Updated = themeDir.ModTime().Format("2006-01-02 15:04:05") theme.Updated = themeDir.ModTime().Format("2006-01-02 15:04:05")
theme.Size = themeDir.Size()
theme.HSize = humanize.Bytes(uint64(theme.Size))
theme.HUpdated = formatUpdated(theme.Updated) theme.HUpdated = formatUpdated(theme.Updated)
readme, readErr := os.ReadFile(filepath.Join(util.ThemesPath, dirName, "README.md")) installSize, _ := util.SizeOfDirectory(installPath)
theme.InstallSize = installSize
theme.HInstallSize = humanize.Bytes(uint64(installSize))
readme, readErr := os.ReadFile(filepath.Join(installPath, "README.md"))
if nil != readErr { if nil != readErr {
logging.LogWarnf("read install theme README.md failed: %s", readErr) logging.LogWarnf("read install theme README.md failed: %s", readErr)
continue continue

View file

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

View file

@ -288,7 +288,7 @@ func uploadCloud(sqlAssets []*sql.Asset) (err error) {
if fi, statErr := os.Stat(absAsset); nil != statErr { if fi, statErr := os.Stat(absAsset); nil != statErr {
logging.LogErrorf("stat file [%s] failed: %s", absAsset, statErr) logging.LogErrorf("stat file [%s] failed: %s", absAsset, statErr)
return statErr return statErr
} else if util.CloudSingleFileMaxSizeLimit/10 <= fi.Size() { } else if 10*1024*1024 <= fi.Size() {
logging.LogWarnf("file [%s] larger than 10MB, ignore uploading it", absAsset) logging.LogWarnf("file [%s] larger than 10MB, ignore uploading it", absAsset)
continue continue
} }

View file

@ -190,23 +190,14 @@ func IsSubFolder(parent, sub string) bool {
return false return false
} }
const CloudSingleFileMaxSizeLimit = 96 * 1000 * 1000 func SizeOfDirectory(path string) (size int64, err error) {
err = filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
func SizeOfDirectory(path string, includeBigFile bool) (int64, error) {
var size int64
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
if nil != err { if nil != err {
return err return err
} }
if !info.IsDir() { if !info.IsDir() {
s := info.Size() s := info.Size()
if CloudSingleFileMaxSizeLimit < s {
if includeBigFile {
size += s size += s
}
} else {
size += s
}
} else { } else {
size += 4096 size += 4096
} }
@ -215,7 +206,7 @@ func SizeOfDirectory(path string, includeBigFile bool) (int64, error) {
if nil != err { if nil != err {
logging.LogErrorf("size of dir [%s] failed: %s", path, err) logging.LogErrorf("size of dir [%s] failed: %s", path, err)
} }
return size, err return
} }
func IsReservedFilename(baseName string) bool { func IsReservedFilename(baseName string) bool {

View file

@ -41,7 +41,7 @@ const (
) )
func logBootInfo() { func logBootInfo() {
s, _ := SizeOfDirectory(DataDir, true) s, _ := SizeOfDirectory(DataDir)
dataDirSize := humanize.Bytes(uint64(s)) dataDirSize := humanize.Bytes(uint64(s))
logging.LogInfof("kernel is booting:\n"+ logging.LogInfof("kernel is booting:\n"+