Bug 293086

Summary: Sorting by file size broken in some cases
Product: [Applications] dolphin Reporter: Georg Hennig <georg298>
Component: view-engine: generalAssignee: Peter Penz <peter.penz19>
Status: RESOLVED FIXED    
Severity: normal CC: arichardson.kde, Ronny.Standtke
Priority: NOR Keywords: regression
Version: 2.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In: 4.8.1
Sentry Crash Report:
Attachments: Screenshot (part of dolphin's list view) with wrong sorting

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. ***