Don't double-count size of directories in DirectorySizeJob
AbandonedPublic

Authored by davidedmundson on Nov 21 2018, 12:18 PM.

Details

Reviewers
dfaure
Summary

Running "stat" on a directory gives a size of on ext3 gives a size of
"4096".

DirectorySizeJob has a bug that it counts this directory size twice.
Once when it encounters a directory in the entry list, then again when
it finds the "." entry in that subdirectory.

The unit test passes because it's super vague to be file system
independent.

Diff Detail

Repository
R241 KIO
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 5209
Build 5227: arc lint + arc unit
Restricted Application added a project: Frameworks. · View Herald TranscriptNov 21 2018, 12:18 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
davidedmundson requested review of this revision.Nov 21 2018, 12:18 PM
davidedmundson abandoned this revision.Nov 21 2018, 1:18 PM
adridg added a subscriber: adridg.Nov 22 2018, 3:13 PM

With UFS, stat(1) tells me

[adridg@beastie .../kio/build]$ stat .
2080587972 222556 drwxr-xr-x 9 adridg adridg 4294967295 17 "Nov 22 14:40:28 2018" "Nov 22 14:42:22 2018" "Nov 22 14:42:22 2018" "Nov 22 14:39:51 2018" 131072 17 0x800 .

So that's a size of 17 -- on UFS that looks like the count of the files in the directory (I added a file and then size is 18).

Without this patch: jobtest has 71 tests, all pass.
With this patch: jobtest has 71 tests, 1 fails.

QDEBUG : JobTest::directorySize() totalSize:  50
QDEBUG : JobTest::directorySize() totalFiles:  7
QDEBUG : JobTest::directorySize() totalSubdirs:  4
FAIL!  : JobTest::directorySize() 'job->totalSize() >= 60' returned FALSE. (totalSize was 50)
   Loc: [/home/adridg/src/kde/tier-3/kio/autotests/jobtest.cpp(1099)]

With this patch, and D17071 as well, the failure is the same: 71 tests, 1 fails, same case and failure message.

(Note that I ran the test against Frameworks 5.51, since I don't have 5.52 installed yet)