mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 08:00:13 +01:00
🎨 Improve disk usage display https://github.com/siyuan-note/siyuan/issues/11121
This commit is contained in:
parent
7949cfa1bc
commit
ffb44137f2
7 changed files with 27 additions and 27 deletions
|
|
@ -82,7 +82,7 @@ func statAsset(c *gin.Context) {
|
||||||
|
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"size": info.Size(),
|
"size": info.Size(),
|
||||||
"hSize": humanize.Bytes(uint64(info.Size())),
|
"hSize": humanize.BytesCustomCeil(uint64(info.Size()), 2),
|
||||||
"created": created,
|
"created": created,
|
||||||
"hCreated": hCreated,
|
"hCreated": hCreated,
|
||||||
"updated": updated,
|
"updated": updated,
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,7 @@ func fromSQLAssetContent(assetContent *sql.AssetContent, beforeLen int) *AssetCo
|
||||||
Ext: assetContent.Ext,
|
Ext: assetContent.Ext,
|
||||||
Path: assetContent.Path,
|
Path: assetContent.Path,
|
||||||
Size: assetContent.Size,
|
Size: assetContent.Size,
|
||||||
HSize: humanize.Bytes(uint64(assetContent.Size)),
|
HSize: humanize.BytesCustomCeil(uint64(assetContent.Size), 2),
|
||||||
Updated: assetContent.Updated,
|
Updated: assetContent.Updated,
|
||||||
Content: content,
|
Content: content,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func StatJob() {
|
||||||
Conf.m.Unlock()
|
Conf.m.Unlock()
|
||||||
Conf.Save()
|
Conf.Save()
|
||||||
|
|
||||||
logging.LogInfof("auto stat [trees=%d, blocks=%d, dataSize=%s, assetsSize=%s]", Conf.Stat.TreeCount, Conf.Stat.BlockCount, humanize.Bytes(uint64(Conf.Stat.DataSize)), humanize.Bytes(uint64(Conf.Stat.AssetsSize)))
|
logging.LogInfof("auto stat [trees=%d, blocks=%d, dataSize=%s, assetsSize=%s]", Conf.Stat.TreeCount, Conf.Stat.BlockCount, humanize.BytesCustomCeil(uint64(Conf.Stat.DataSize), 2), humanize.BytesCustomCeil(uint64(Conf.Stat.AssetsSize), 2))
|
||||||
|
|
||||||
// 桌面端检查磁盘可用空间 https://github.com/siyuan-note/siyuan/issues/6873
|
// 桌面端检查磁盘可用空间 https://github.com/siyuan-note/siyuan/issues/6873
|
||||||
if util.ContainerStd != util.Container {
|
if util.ContainerStd != util.Container {
|
||||||
|
|
|
||||||
|
|
@ -851,7 +851,7 @@ func InitBoxes() {
|
||||||
|
|
||||||
var dbSize string
|
var dbSize string
|
||||||
if dbFile, err := os.Stat(util.DBPath); nil == err {
|
if dbFile, err := os.Stat(util.DBPath); nil == err {
|
||||||
dbSize = humanize.Bytes(uint64(dbFile.Size()))
|
dbSize = humanize.BytesCustomCeil(uint64(dbFile.Size()), 2)
|
||||||
}
|
}
|
||||||
logging.LogInfof("database size [%s], tree/block count [%d/%d]", dbSize, treenode.CountTrees(), treenode.CountBlocks())
|
logging.LogInfof("database size [%s], tree/block count [%d/%d]", dbSize, treenode.CountTrees(), treenode.CountBlocks())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ func (box *Box) docFromFileInfo(fileInfo *FileInfo, ial map[string]string) (ret
|
||||||
t, _ := time.ParseInLocation("20060102150405", ret.ID[:14], time.Local)
|
t, _ := time.ParseInLocation("20060102150405", ret.ID[:14], time.Local)
|
||||||
ret.CTime = t.Unix()
|
ret.CTime = t.Unix()
|
||||||
ret.HCtime = t.Format("2006-01-02 15:04:05")
|
ret.HCtime = t.Format("2006-01-02 15:04:05")
|
||||||
ret.HSize = humanize.Bytes(ret.Size)
|
ret.HSize = humanize.BytesCustomCeil(ret.Size, 2)
|
||||||
|
|
||||||
mTime := t
|
mTime := t
|
||||||
if updated := ial["updated"]; "" != updated {
|
if updated := ial["updated"]; "" != updated {
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ func DiffRepoSnapshots(left, right string) (ret *LeftRightDiff, err error) {
|
||||||
FileID: removeRight.ID,
|
FileID: removeRight.ID,
|
||||||
Title: title,
|
Title: title,
|
||||||
Path: removeRight.Path,
|
Path: removeRight.Path,
|
||||||
HSize: humanize.Bytes(uint64(removeRight.Size)),
|
HSize: humanize.BytesCustomCeil(uint64(removeRight.Size), 2),
|
||||||
Updated: removeRight.Updated,
|
Updated: removeRight.Updated,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -251,7 +251,7 @@ func DiffRepoSnapshots(left, right string) (ret *LeftRightDiff, err error) {
|
||||||
FileID: addLeft.ID,
|
FileID: addLeft.ID,
|
||||||
Title: title,
|
Title: title,
|
||||||
Path: addLeft.Path,
|
Path: addLeft.Path,
|
||||||
HSize: humanize.Bytes(uint64(addLeft.Size)),
|
HSize: humanize.BytesCustomCeil(uint64(addLeft.Size), 2),
|
||||||
Updated: addLeft.Updated,
|
Updated: addLeft.Updated,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -269,7 +269,7 @@ func DiffRepoSnapshots(left, right string) (ret *LeftRightDiff, err error) {
|
||||||
FileID: updateLeft.ID,
|
FileID: updateLeft.ID,
|
||||||
Title: title,
|
Title: title,
|
||||||
Path: updateLeft.Path,
|
Path: updateLeft.Path,
|
||||||
HSize: humanize.Bytes(uint64(updateLeft.Size)),
|
HSize: humanize.BytesCustomCeil(uint64(updateLeft.Size), 2),
|
||||||
Updated: updateLeft.Updated,
|
Updated: updateLeft.Updated,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +287,7 @@ func DiffRepoSnapshots(left, right string) (ret *LeftRightDiff, err error) {
|
||||||
FileID: updateRight.ID,
|
FileID: updateRight.ID,
|
||||||
Title: title,
|
Title: title,
|
||||||
Path: updateRight.Path,
|
Path: updateRight.Path,
|
||||||
HSize: humanize.Bytes(uint64(updateRight.Size)),
|
HSize: humanize.BytesCustomCeil(uint64(updateRight.Size), 2),
|
||||||
Updated: updateRight.Updated,
|
Updated: updateRight.Updated,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -500,7 +500,7 @@ func PurgeCloud() (err error) {
|
||||||
|
|
||||||
deletedIndexes := stat.Indexes
|
deletedIndexes := stat.Indexes
|
||||||
deletedObjects := stat.Objects
|
deletedObjects := stat.Objects
|
||||||
deletedSize := humanize.Bytes(uint64(stat.Size))
|
deletedSize := humanize.BytesCustomCeil(uint64(stat.Size), 2)
|
||||||
msg = fmt.Sprintf(Conf.Language(232), deletedIndexes, deletedObjects, deletedSize)
|
msg = fmt.Sprintf(Conf.Language(232), deletedIndexes, deletedObjects, deletedSize)
|
||||||
util.PushMsg(msg, 5000)
|
util.PushMsg(msg, 5000)
|
||||||
return
|
return
|
||||||
|
|
@ -523,7 +523,7 @@ func PurgeRepo() (err error) {
|
||||||
|
|
||||||
deletedIndexes := stat.Indexes
|
deletedIndexes := stat.Indexes
|
||||||
deletedObjects := stat.Objects
|
deletedObjects := stat.Objects
|
||||||
deletedSize := humanize.Bytes(uint64(stat.Size))
|
deletedSize := humanize.BytesCustomCeil(uint64(stat.Size), 2)
|
||||||
msg = fmt.Sprintf(Conf.Language(203), deletedIndexes, deletedObjects, deletedSize)
|
msg = fmt.Sprintf(Conf.Language(203), deletedIndexes, deletedObjects, deletedSize)
|
||||||
util.PushMsg(msg, 5000)
|
util.PushMsg(msg, 5000)
|
||||||
return
|
return
|
||||||
|
|
@ -696,7 +696,7 @@ func DownloadCloudSnapshot(tag, id string) (err error) {
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf(Conf.Language(153), downloadFileCount, downloadChunkCount, humanize.Bytes(uint64(downloadBytes)))
|
msg := fmt.Sprintf(Conf.Language(153), downloadFileCount, downloadChunkCount, humanize.BytesCustomCeil(uint64(downloadBytes), 2))
|
||||||
util.PushMsg(msg, 5000)
|
util.PushMsg(msg, 5000)
|
||||||
util.PushStatusBar(msg)
|
util.PushStatusBar(msg)
|
||||||
return
|
return
|
||||||
|
|
@ -737,7 +737,7 @@ func UploadCloudSnapshot(tag, id string) (err error) {
|
||||||
err = errors.New(fmt.Sprintf(Conf.Language(84), formatRepoErrorMsg(err)))
|
err = errors.New(fmt.Sprintf(Conf.Language(84), formatRepoErrorMsg(err)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf(Conf.Language(152), uploadFileCount, uploadChunkCount, humanize.Bytes(uint64(uploadBytes)))
|
msg := fmt.Sprintf(Conf.Language(152), uploadFileCount, uploadChunkCount, humanize.BytesCustomCeil(uint64(uploadBytes), 2))
|
||||||
util.PushMsg(msg, 5000)
|
util.PushMsg(msg, 5000)
|
||||||
util.PushStatusBar(msg)
|
util.PushStatusBar(msg)
|
||||||
return
|
return
|
||||||
|
|
@ -1039,9 +1039,9 @@ func syncRepoDownload() (err error) {
|
||||||
msg := fmt.Sprintf(Conf.Language(80), formatRepoErrorMsg(err))
|
msg := fmt.Sprintf(Conf.Language(80), formatRepoErrorMsg(err))
|
||||||
if errors.Is(err, dejavu.ErrCloudStorageSizeExceeded) {
|
if errors.Is(err, dejavu.ErrCloudStorageSizeExceeded) {
|
||||||
u := Conf.GetUser()
|
u := Conf.GetUser()
|
||||||
msg = fmt.Sprintf(Conf.Language(43), humanize.Bytes(uint64(u.UserSiYuanRepoSize)))
|
msg = fmt.Sprintf(Conf.Language(43), humanize.BytesCustomCeil(uint64(u.UserSiYuanRepoSize), 2))
|
||||||
if 2 == u.UserSiYuanSubscriptionPlan {
|
if 2 == u.UserSiYuanSubscriptionPlan {
|
||||||
msg = fmt.Sprintf(Conf.Language(68), humanize.Bytes(uint64(u.UserSiYuanRepoSize)))
|
msg = fmt.Sprintf(Conf.Language(68), humanize.BytesCustomCeil(uint64(u.UserSiYuanRepoSize), 2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Conf.Sync.Stat = msg
|
Conf.Sync.Stat = msg
|
||||||
|
|
@ -1053,7 +1053,7 @@ func syncRepoDownload() (err error) {
|
||||||
|
|
||||||
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
||||||
Conf.Sync.Synced = util.CurrentTimeMillis()
|
Conf.Sync.Synced = util.CurrentTimeMillis()
|
||||||
msg := fmt.Sprintf(Conf.Language(150), trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)))
|
msg := fmt.Sprintf(Conf.Language(150), trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.BytesCustomCeil(uint64(trafficStat.UploadBytes), 2), humanize.BytesCustomFloor(uint64(trafficStat.DownloadBytes), 2))
|
||||||
Conf.Sync.Stat = msg
|
Conf.Sync.Stat = msg
|
||||||
Conf.Save()
|
Conf.Save()
|
||||||
autoSyncErrCount = 0
|
autoSyncErrCount = 0
|
||||||
|
|
@ -1110,9 +1110,9 @@ func syncRepoUpload() (err error) {
|
||||||
msg := fmt.Sprintf(Conf.Language(80), formatRepoErrorMsg(err))
|
msg := fmt.Sprintf(Conf.Language(80), formatRepoErrorMsg(err))
|
||||||
if errors.Is(err, dejavu.ErrCloudStorageSizeExceeded) {
|
if errors.Is(err, dejavu.ErrCloudStorageSizeExceeded) {
|
||||||
u := Conf.GetUser()
|
u := Conf.GetUser()
|
||||||
msg = fmt.Sprintf(Conf.Language(43), humanize.Bytes(uint64(u.UserSiYuanRepoSize)))
|
msg = fmt.Sprintf(Conf.Language(43), humanize.BytesCustomCeil(uint64(u.UserSiYuanRepoSize), 2))
|
||||||
if 2 == u.UserSiYuanSubscriptionPlan {
|
if 2 == u.UserSiYuanSubscriptionPlan {
|
||||||
msg = fmt.Sprintf(Conf.Language(68), humanize.Bytes(uint64(u.UserSiYuanRepoSize)))
|
msg = fmt.Sprintf(Conf.Language(68), humanize.BytesCustomCeil(uint64(u.UserSiYuanRepoSize), 2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Conf.Sync.Stat = msg
|
Conf.Sync.Stat = msg
|
||||||
|
|
@ -1124,7 +1124,7 @@ func syncRepoUpload() (err error) {
|
||||||
|
|
||||||
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
||||||
Conf.Sync.Synced = util.CurrentTimeMillis()
|
Conf.Sync.Synced = util.CurrentTimeMillis()
|
||||||
msg := fmt.Sprintf(Conf.Language(150), trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)))
|
msg := fmt.Sprintf(Conf.Language(150), trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.BytesCustomCeil(uint64(trafficStat.UploadBytes), 2), humanize.BytesCustomCeil(uint64(trafficStat.DownloadBytes), 2))
|
||||||
Conf.Sync.Stat = msg
|
Conf.Sync.Stat = msg
|
||||||
Conf.Save()
|
Conf.Save()
|
||||||
autoSyncErrCount = 0
|
autoSyncErrCount = 0
|
||||||
|
|
@ -1218,9 +1218,9 @@ func bootSyncRepo() (err error) {
|
||||||
msg := fmt.Sprintf(Conf.Language(80), formatRepoErrorMsg(err))
|
msg := fmt.Sprintf(Conf.Language(80), formatRepoErrorMsg(err))
|
||||||
if errors.Is(err, dejavu.ErrCloudStorageSizeExceeded) {
|
if errors.Is(err, dejavu.ErrCloudStorageSizeExceeded) {
|
||||||
u := Conf.GetUser()
|
u := Conf.GetUser()
|
||||||
msg = fmt.Sprintf(Conf.Language(43), humanize.Bytes(uint64(u.UserSiYuanRepoSize)))
|
msg = fmt.Sprintf(Conf.Language(43), humanize.BytesCustomCeil(uint64(u.UserSiYuanRepoSize), 2))
|
||||||
if 2 == u.UserSiYuanSubscriptionPlan {
|
if 2 == u.UserSiYuanSubscriptionPlan {
|
||||||
msg = fmt.Sprintf(Conf.Language(68), humanize.Bytes(uint64(u.UserSiYuanRepoSize)))
|
msg = fmt.Sprintf(Conf.Language(68), humanize.BytesCustomCeil(uint64(u.UserSiYuanRepoSize), 2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Conf.Sync.Stat = msg
|
Conf.Sync.Stat = msg
|
||||||
|
|
@ -1303,9 +1303,9 @@ func syncRepo(exit, byHand bool) (dataChanged bool, err error) {
|
||||||
msg := fmt.Sprintf(Conf.Language(80), formatRepoErrorMsg(err))
|
msg := fmt.Sprintf(Conf.Language(80), formatRepoErrorMsg(err))
|
||||||
if errors.Is(err, dejavu.ErrCloudStorageSizeExceeded) {
|
if errors.Is(err, dejavu.ErrCloudStorageSizeExceeded) {
|
||||||
u := Conf.GetUser()
|
u := Conf.GetUser()
|
||||||
msg = fmt.Sprintf(Conf.Language(43), humanize.Bytes(uint64(u.UserSiYuanRepoSize)))
|
msg = fmt.Sprintf(Conf.Language(43), humanize.BytesCustomCeil(uint64(u.UserSiYuanRepoSize), 2))
|
||||||
if 2 == u.UserSiYuanSubscriptionPlan {
|
if 2 == u.UserSiYuanSubscriptionPlan {
|
||||||
msg = fmt.Sprintf(Conf.Language(68), humanize.Bytes(uint64(u.UserSiYuanRepoSize)))
|
msg = fmt.Sprintf(Conf.Language(68), humanize.BytesCustomCeil(uint64(u.UserSiYuanRepoSize), 2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Conf.Sync.Stat = msg
|
Conf.Sync.Stat = msg
|
||||||
|
|
@ -1324,7 +1324,7 @@ func syncRepo(exit, byHand bool) (dataChanged bool, err error) {
|
||||||
|
|
||||||
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
||||||
Conf.Sync.Synced = util.CurrentTimeMillis()
|
Conf.Sync.Synced = util.CurrentTimeMillis()
|
||||||
msg := fmt.Sprintf(Conf.Language(150), trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)))
|
msg := fmt.Sprintf(Conf.Language(150), trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.BytesCustomCeil(uint64(trafficStat.UploadBytes), 2), humanize.BytesCustomCeil(uint64(trafficStat.DownloadBytes), 2))
|
||||||
Conf.Sync.Stat = msg
|
Conf.Sync.Stat = msg
|
||||||
Conf.Save()
|
Conf.Save()
|
||||||
autoSyncErrCount = 0
|
autoSyncErrCount = 0
|
||||||
|
|
@ -1341,7 +1341,7 @@ func syncRepo(exit, byHand bool) (dataChanged bool, err error) {
|
||||||
func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult, trafficStat *dejavu.TrafficStat, mode string, elapsed time.Duration) {
|
func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult, trafficStat *dejavu.TrafficStat, mode string, elapsed time.Duration) {
|
||||||
logging.LogInfof("synced data repo [device=%s, kernel=%s, provider=%d, mode=%s/%t, ufc=%d, dfc=%d, ucc=%d, dcc=%d, ub=%s, db=%s] in [%.2fs], merge result [conflicts=%d, upserts=%d, removes=%d]\n\n",
|
logging.LogInfof("synced data repo [device=%s, kernel=%s, provider=%d, mode=%s/%t, ufc=%d, dfc=%d, ucc=%d, dcc=%d, ub=%s, db=%s] in [%.2fs], merge result [conflicts=%d, upserts=%d, removes=%d]\n\n",
|
||||||
Conf.System.ID, KernelID, Conf.Sync.Provider, mode, byHand,
|
Conf.System.ID, KernelID, Conf.Sync.Provider, mode, byHand,
|
||||||
trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)),
|
trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.BytesCustomCeil(uint64(trafficStat.UploadBytes), 2), humanize.BytesCustomCeil(uint64(trafficStat.DownloadBytes), 2),
|
||||||
elapsed.Seconds(),
|
elapsed.Seconds(),
|
||||||
len(mergeResult.Conflicts), len(mergeResult.Upserts), len(mergeResult.Removes))
|
len(mergeResult.Conflicts), len(mergeResult.Upserts), len(mergeResult.Removes))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -543,13 +543,13 @@ func ListCloudSyncDir() (syncDirs []*Sync, hSize string, err error) {
|
||||||
CloudName: d.Name,
|
CloudName: d.Name,
|
||||||
}
|
}
|
||||||
if conf.ProviderSiYuan == Conf.Sync.Provider {
|
if conf.ProviderSiYuan == Conf.Sync.Provider {
|
||||||
sync.HSize = humanize.Bytes(uint64(dirSize))
|
sync.HSize = humanize.BytesCustomCeil(uint64(dirSize), 2)
|
||||||
}
|
}
|
||||||
syncDirs = append(syncDirs, sync)
|
syncDirs = append(syncDirs, sync)
|
||||||
}
|
}
|
||||||
hSize = "-"
|
hSize = "-"
|
||||||
if conf.ProviderSiYuan == Conf.Sync.Provider {
|
if conf.ProviderSiYuan == Conf.Sync.Provider {
|
||||||
hSize = humanize.Bytes(uint64(size))
|
hSize = humanize.BytesCustomCeil(uint64(size), 2)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue