From 925e8bcfe18c37bcb06db2caf0eb14f59b32c9cd Mon Sep 17 00:00:00 2001 From: robobun Date: Mon, 10 Nov 2025 20:02:00 -0800 Subject: [PATCH] Format download sizes in human-readable format (#24266) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Use `std.fmt.fmtIntSizeBin` to format progress indicators with byte sizes - Improves readability during operations like `bun upgrade` - Changes display from raw bytes (e.g., "23982378/2398284") to human-readable format (e.g., "23.2MiB/100MiB") ## Changes Modified `src/Progress.zig`: - Updated progress formatting to use `std.fmt.fmtIntSizeBin` for both current and total sizes - Applied to both progress with total (`[current/total unit]`) and without total (`[current unit]`) ## Test plan - [x] Build succeeds with `bun bd` - [ ] Manual verification with `bun upgrade` shows human-readable sizes Fixes #24226 fixes #7826 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Bot Co-authored-by: Claude Co-authored-by: pfg --- src/Progress.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Progress.zig b/src/Progress.zig index 788745f772..55777fde8a 100644 --- a/src/Progress.zig +++ b/src/Progress.zig @@ -326,11 +326,17 @@ fn refreshWithHeldLock(self: *Progress) void { } if (eti > 0) { if (need_ellipse) self.bufWrite(&end, " ", .{}); - self.bufWrite(&end, "[{d}/{d}{s}] ", .{ current_item, eti, node.unit }); + switch (node.unit.len == 0) { + true => self.bufWrite(&end, "[{Bi:.2}/{Bi:.2}] ", .{ current_item, eti }), + false => self.bufWrite(&end, "[{d}/{d}{s}] ", .{ current_item, eti, node.unit }), + } need_ellipse = false; } else if (completed_items != 0) { if (need_ellipse) self.bufWrite(&end, " ", .{}); - self.bufWrite(&end, "[{d}{s}] ", .{ current_item, node.unit }); + switch (node.unit.len == 0) { + true => self.bufWrite(&end, "[{Bi:.2}] ", .{current_item}), + false => self.bufWrite(&end, "[{d}{s}] ", .{ current_item, node.unit }), + } need_ellipse = false; } }