1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-23 22:05:07 +00:00

fix: use Base-10 sizes and mdls logical size to match macOS Finder

- Switch bytes_to_human (shell) and humanizeBytes (Go) from Base-2
  (1024) to Base-10 (1000) to match Apple's storage calculation
  standard since Snow Leopard
- Add proper decimal rounding instead of truncation
- Use mdls kMDItemLogicalSize for .app bundles to avoid APFS clone
  file undercounting by du

Fixes #511
This commit is contained in:
tw93
2026-02-28 10:02:34 +08:00
parent 646ff72a96
commit 1be71edc9d
4 changed files with 36 additions and 20 deletions

View File

@@ -80,7 +80,7 @@ func humanizeBytes(size int64) string {
if size < 0 {
return "0 B"
}
const unit = 1024
const unit = 1000
if size < unit {
return fmt.Sprintf("%d B", size)
}
@@ -90,7 +90,7 @@ func humanizeBytes(size int64) string {
exp++
}
value := float64(size) / float64(div)
return fmt.Sprintf("%.1f %cB", value, "KMGTPE"[exp])
return fmt.Sprintf("%.1f %cB", value, "kMGTPE"[exp])
}
func coloredProgressBar(value, maxValue int64, percent float64) string {