Bug 293086 - Sorting by file size broken in some cases
Summary: Sorting by file size broken in some cases
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: general (show other bugs)
Version: 2.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Peter Penz
URL:
Keywords: regression
: 293291 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-02-01 21:56 UTC by Georg Hennig
Modified: 2012-02-04 14:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.8.1


Attachments
Screenshot (part of dolphin's list view) with wrong sorting (46.42 KB, image/png)
2012-02-01 21:56 UTC, Georg Hennig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Georg Hennig 2012-02-01 21:56:43 UTC
Created attachment 68413 [details]
Screenshot (part of dolphin's list view) with wrong sorting

Version:           2.0 (using KDE 4.8.0) 
OS:                Linux

Dolphin (and Konqueror) don't show files sorted correctly by file size: some files are randomly distributed in the list of sorted files.

The file system is a NTFS (ntfs-3g) file system with very large files.

Probably this is related to the bug that the file size is only reported in KiB units (very practical for GiB files... :-) 




Reproducible: Always

Steps to Reproduce:
I don't know how to reproduce it. This is my setup:
- NTFS file system
- Some files (all? of them > 1GiB) are not affected by sorting by file size


Expected Results:  
File size is reported correctly. ls -S is working correctly. Dolphin should work correctly, too.
Dolphin fails to show correct units for file size.
Comment 1 Alex Richardson 2012-02-02 01:56:20 UTC
This seems to be the same issue I am running into.

I have a folder with a file with 2 600 000 KB size.
When I sort by size a file with 2 200 000 KB is shown as the largest file, then sorting is correct until right at the bottom, where my 2.6 GB file is displayed
as the smallest element.

I am pretty sure this has something to do with integer overflow.

However the strange thing is that a file with 2 666 563 584 bytes is shown as being the smallest, whereas a file with 2 299 033 600 bytes is the largest. Since the maximum value a signed 32 bit integer can hold is only 2 147 483 647 bytes, I would have expected that file to be at the bottom of the list, too.
Comment 2 Peter Penz 2012-02-02 15:02:53 UTC
Git commit e196f065efeb911db931f549004daa8d9bbaa914 by Peter Penz.
Committed on 02/02/2012 at 15:58.
Pushed by ppenz into branch 'KDE/4.8'.

Fix sorting issue when sorting by "size"

Root cause of the issue was an overflow in:
result = a - b;
where result is 'int' and a and b are 'KIO::filesize_t'.
FIXED-IN: 4.8.1

M  +20   -6    dolphin/src/kitemviews/kfileitemmodel.cpp
M  +6    -0    dolphin/src/kitemviews/kfileitemmodel.h

http://commits.kde.org/kde-baseapps/e196f065efeb911db931f549004daa8d9bbaa914
Comment 3 Peter Penz 2012-02-02 15:03:38 UTC
Git commit 534b9c4f033859dd811ad4bad3b5283aaadaf24a by Peter Penz.
Committed on 02/02/2012 at 15:58.
Pushed by ppenz into branch 'master'.

Fix sorting issue when sorting by "size"

Root cause of the issue was an overflow in:
result = a - b;
where result is 'int' and a and b are 'KIO::filesize_t'.
FIXED-IN: 4.8.1

M  +20   -6    dolphin/src/kitemviews/kfileitemmodel.cpp
M  +6    -0    dolphin/src/kitemviews/kfileitemmodel.h

http://commits.kde.org/kde-baseapps/534b9c4f033859dd811ad4bad3b5283aaadaf24a
Comment 4 Peter Penz 2012-02-04 14:18:03 UTC
*** Bug 293291 has been marked as a duplicate of this bug. ***