! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
thunar incorrectly showing file sizes
Status:
RESOLVED: FIXED
Severity:
critical

Comments

Description Yousuf 'Jay' Philips 2014-05-02 13:22:00 CEST
thunar is dividing by 1000 rather than 1024 when converting file sizes to kilobytes, megabytes and gigabytes.
Comment 1 Andrzej editbugs 2014-05-04 21:27:48 CEST
By definition kilo=10^3, mega=10^6, so this is not a bug.

AFAIR there was some talk about adding extra/optional binary prefixes (2^10, 2^20) but no one has stepped forward to implement it. Patches welcome.
Comment 2 toyeisfree 2014-07-11 22:35:51 CEST
the correct term is in base 2, as the correct units are bits, bytes, Kibibyte (KiB) mebibyte (MiB) gibibyte (GiB), etc..

I hope in the future, thunar show sizes in KiB MiB GiB etc
Comment 3 Ralf Teres 2014-11-10 01:20:00 CET
This is neither new, nor a bug. Please see Bug Report #9887.
https://bugzilla.xfce.org/show_bug.cgi?id=9887
Comment 4 Andre Miranda editbugs 2014-11-22 19:35:01 CET
Even though the Glib docs says we should use base 1000 to display "Network and storage sizes" I don't agree. They might have their rationale for this, but almost everything else displays KiB as KB(I know this is wrong) or at the best, they display file size as KiB. Even browsers(Firefox, Chromium...) and the majority of websites display KiB as KB. They are not ignorants or idiots, they're just not trying to confuse users.

All in all, I think that Thunar should use base 1024 notation, because it's not wrong and it's no confusing for the user, for example: "Oh, I downloaded this 60,4 MB file(the site and the browser told the user this), but Thunar says this is 63.3 MB". The funny thing is that if everybody is not following the standard, the one that follows is seen as wrong.

So, if I or someone else submit a patch in order to "fix" this, will TPTB accept?
Comment 5 Andrzej editbugs 2014-11-22 22:17:39 CET
André, I am thinking of two solutions:

1. Add a configuration option with a proper GUI and keep the defaults ("k"=10^3). Preferably, call the 2^10 prefix "Ki". If not, switch the column header name to "Size (binary)". In "Properties" dialogs and in the status bar use both systems (e.g. "9.7GB / 9.0GiB").

2. Use two column headers: "Size (decimal)", "Size (binary)" (we can already switch headers on/off). In "Properties" dialogs and in the status bar use both systems (e.g. "9.7GB / 9.0GiB").

If you implement either of these variants I will be happy to push it to master.
Comment 6 Andre Miranda editbugs 2014-11-26 01:51:37 CET
I guess the first one is more sensible, the second is too much clutter.

I'm tinkering the source, but I don't know how we could call this option:
"Use base 1024 for filesize"?
"Display filesize in IEC units"?

Also, where should this option be put? Preferences -> Display -> Default View? Or a new section in Display tab?
Comment 7 Yousuf 'Jay' Philips 2014-11-26 05:25:34 CET
Hi Andre,

Thanks for taking this on. :D

I had seen this setting in Cinammon's Nemo file manager. In its 'Display' preferences tab, they had a section titled 'File Size' and then a field label 'Prefixes' next to a drop down menu which contained 'Decimal' and 'Binary'. I hope this helps.
Comment 8 Andre Miranda editbugs 2014-12-17 04:55:48 CET
Created attachment 5820 
Patch

Finally I've come to have a spare time to work on this bug.
Besides the attached patch, here is the commit at my github repo:
https://github.com/andreldm/thunar/commit/5bce93830d1005273a4af0fc45417418c671f28c
Comment 9 Andre Miranda editbugs 2014-12-17 13:25:36 CET
I forgot to mention, this is just a preliminary patch, I'm not sure about the naming of the variables and strings. Also, preferences needs to be "getted" for each call to thunar_file_get_size_string, is there a better way to handle this?
Comment 10 Andrzej editbugs 2014-12-18 02:27:22 CET
Leave thunar_file_get_size_string unchanged and add another function e.g. thunar_file_get_size_string_with_mode (const ThunarFile *file, gboolean mode). Modify thunar-list-model.c (and any other code using thunar_file_get_size_string) to use the new function. Cache the configured value as a property in the ThunarListModel object.
Comment 11 Andre Miranda editbugs 2014-12-19 03:30:07 CET
Created attachment 5821 
Updated patch

The patch has been updated following your recommendations. The github mirror is also up to date.
If you feel everything is good enough, I attach another patch with commit info.
Comment 12 Andrzej editbugs 2014-12-20 01:41:45 CET
I've merged your git branch into master. Thank you, that's a good quality code.

BTW, the status bar always uses decimal units. Also, the properties dialog could display both units at once - no need to make it configurable.
Comment 13 Andre Miranda editbugs 2014-12-20 19:01:13 CET
Thanks Andrzej for merging this so fast.
What do you mean by the status bar always showing sizes in decimal units?
If you set in preferences the check for binary format, after closing the dialog you need to selected another file to see the change.
Regarding the properties dialog, I guess it would be clutter to show sizes in binary units, decimal units *and bytes*, which is a hint for the size in kB, MB...
Comment 14 Steve Dodier-Lazaro editbugs 2015-02-10 16:47:40 CET
Should I mark this report as RESOLVED FIXED?
Comment 15 toyeisfree 2015-02-10 18:43:27 CET
(In reply to Steve Dodier-Lazaro from comment #14)
> Should I mark this report as RESOLVED FIXED?

Yes ! you can, Thanks for all
Comment 16 Andre Miranda editbugs 2015-02-10 18:55:17 CET
I'm using Thunar from git for a while and so far I haven't spotted any problem.
It'd be great if someone else(besides me and Andrzej) could review the implementation, but if by any case someone notice a bug or an improvement, we can handle that in another bug report.

@Steve, I'm going ahead of you and closing this bug =)
Comment 17 toyeisfree 2015-02-10 19:02:21 CET
I'm using Thunar from git too and all work perfect
Comment 18 Steve Dodier-Lazaro editbugs 2015-02-12 03:47:37 CET
Looking back at the patch, I don't think the misc-file-size-binary key is important enough to have a UI setting of its own (introduced in the patch). Any views on that?

Bug #10864

Reported by:
Yousuf 'Jay' Philips
Reported on: 2014-05-02
Last modified on: 2015-02-12

People

Assignee:
Andre Miranda
CC List:
6 users

Version

Attachments

Patch (14.58 KB, patch)
2014-12-17 04:55 CET , Andre Miranda
no flags
Updated patch (43.29 KB, patch)
2014-12-19 03:30 CET , Andre Miranda
no flags

Additional information