athityakumar / colorls

A Ruby gem that beautifies the terminal's ls command, with color and font-awesome icons. :tada:
MIT License
4.87k stars 385 forks source link

Rounding bug for large files #600

Closed draptik closed 1 day ago

draptik commented 11 months ago

Files larger than 1GB are rounded wrong?

Example:

~/Downloads
❯ colorls -l *img
   rw-r--r--   1   patrick   patrick      1 GiB   Fri Sep 29 20:42:49 2023    2023-05-03-raspios-bullseye-arm64-lite.img
   rw-r--r--   1   patrick   patrick      1 GiB   Fri Sep 29 20:41:50 2023    2023-05-03-raspios-bullseye-armhf-lite.img

~/Downloads
❯ ls -alh *img
-rw-r--r-- 1 patrick patrick 2.0G Sep 29 20:42 2023-05-03-raspios-bullseye-arm64-lite.img
-rw-r--r-- 1 patrick patrick 1.9G Sep 29 20:41 2023-05-03-raspios-bullseye-armhf-lite.img

~/Downloads
❯ ls -al *img
-rw-r--r-- 1 patrick patrick 2101346304 Sep 29 20:42 2023-05-03-raspios-bullseye-arm64-lite.img
-rw-r--r-- 1 patrick patrick 1967128576 Sep 29 20:41 2023-05-03-raspios-bullseye-armhf-lite.img

Both files are more 2GB-like, than 1GB-like.

colorls: 1.4.6 zsh: 5.9 os: arch

avdv commented 10 months ago

Thank you for raising this issue. I can confirm this is a problem in our code, we always cut off the 3 rightmost characters (internally the size is formatted with 2 digits after the decimal point) here https://github.com/athityakumar/colorls/blob/24e402c153274dc5b9cde89ad6235ac5a4746129/lib/colorls/core.rb#L283

ayushpoddar commented 1 month ago

I want to pick it up @avdv

avdv commented 1 month ago

I want to pick it up @avdv

Sure, thank you!

ayushpoddar commented 1 month ago

@avdv I have raised the PR: https://github.com/athityakumar/colorls/pull/622

avdv commented 1 day ago

Fixed by #622