colorls icon indicating copy to clipboard operation
colorls copied to clipboard

Rounding bug for large files

Open draptik opened this issue 2 years ago • 4 comments

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.

  • Type of issue :
    • [x] Bug in existing feature

colorls: 1.4.6 zsh: 5.9 os: arch

draptik avatar Sep 29 '23 19:09 draptik

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

avdv avatar Nov 06 '23 19:11 avdv

I want to pick it up @avdv

ayushpoddar avatar Jul 21 '24 10:07 ayushpoddar

I want to pick it up @avdv

Sure, thank you!

avdv avatar Jul 21 '24 15:07 avdv

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

ayushpoddar avatar Jul 31 '24 20:07 ayushpoddar