mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Format download sizes in human-readable format (#24266)
## 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 <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: pfg <pfg@pfg.pw>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user