1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-23 19:55: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

@@ -63,15 +63,15 @@ func TestHumanizeBytes(t *testing.T) {
{-100, "0 B"},
{0, "0 B"},
{512, "512 B"},
{1023, "1023 B"},
{1024, "1.0 KB"},
{1536, "1.5 KB"},
{10240, "10.0 KB"},
{1048576, "1.0 MB"},
{1572864, "1.5 MB"},
{1073741824, "1.0 GB"},
{1099511627776, "1.0 TB"},
{1125899906842624, "1.0 PB"},
{999, "999 B"},
{1000, "1.0 kB"},
{1500, "1.5 kB"},
{10000, "10.0 kB"},
{1000000, "1.0 MB"},
{1500000, "1.5 MB"},
{1000000000, "1.0 GB"},
{1000000000000, "1.0 TB"},
{1000000000000000, "1.0 PB"},
}
for _, tt := range tests {