🎨 Improve exporting data disk check for desktop-end https://github.com/siyuan-note/siyuan/issues/12473

This commit is contained in:
Daniel 2024-09-16 16:41:50 +08:00
parent 07553bbc35
commit 74d3302b09
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
8 changed files with 43 additions and 6 deletions

View file

@ -33,3 +33,12 @@ func NeedWarnDiskUsage(dataSize int64) bool {
logging.LogInfof("disk usage [total=%s, used=%s, free=%s]", humanize.BytesCustomCeil(usage.Total, 2), humanize.BytesCustomCeil(usage.Used, 2), humanize.BytesCustomCeil(usage.Free, 2))
return usage.Free < uint64(dataSize*2)
}
func GetDiskUsage(p string) (total, used, free uint64) {
usage, err := disk.Usage(p)
if err != nil {
logging.LogErrorf("get disk usage failed: %s", err)
return
}
return usage.Total, usage.Used, usage.Free
}