athityakumar/colorls

Rounding bug for large files

Closed this issue · 5 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 :
    • Bug in existing feature

colorls: 1.4.6
zsh: 5.9
os: arch

avdv commented

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

size_num = size[0][0..-4].rjust(chars_for_size, ' ')

I want to pick it up @avdv

avdv commented

I want to pick it up @avdv

Sure, thank you!

@avdv I have raised the PR: #622

avdv commented

Fixed by #622