[ModifiedFileIndexer] Use correct mimetype for folders, delay until needed
ClosedPublic

Authored by bruns on Jun 9 2019, 10:56 PM.

Details

Summary

mimeTypeForFile is quite expensive (much more than QFileInfo and fetching
the timestamps from the DB), and yields the wrong type for folders.

Diff Detail

Repository
R293 Baloo
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bruns created this revision.Jun 9 2019, 10:56 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptJun 9 2019, 10:56 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
bruns requested review of this revision.Jun 9 2019, 10:56 PM
poboiko added inline comments.Jun 10 2019, 9:10 AM
src/file/modifiedfileindexer.cpp
68

Does it also changes behavior of ModifiedFileIndexer? What happened to symlinks before?

bruns marked an inline comment as done.Jun 10 2019, 3:01 PM
bruns added inline comments.
src/file/modifiedfileindexer.cpp
68

It depends on the state of the PendingFileQueue:

  • when an item is not in the list of recent files, and is new, an indexNewFile signal is emitted, we end up in the NewFileIndexer
  • otherwise, on a 'created' event a indexModifiedFile signal is emitted -> ModifiedFileIndexer

so, on

mkdir target; mkdir test; sleep ...
rmdir test; ln -s target test

we get a deleted and a created event, where the latter ends up in the ModifiedFileIndexer, adding a symlink to the index.

For e.g. the UnindexedFileIndexer, symlinks are omitted using QDir::NoSymlinks.

That said, NewFileIndexer should also check for symlinks.

astippich added inline comments.Jun 10 2019, 8:58 PM
src/file/modifiedfileindexer.cpp
82

"when the folder is created,..." or "when a file is created,..."?

bruns updated this revision to Diff 59564.Jun 10 2019, 11:29 PM
bruns marked an inline comment as done.

update comment

bruns marked an inline comment as done.Jun 10 2019, 11:45 PM
astippich accepted this revision.Jun 12 2019, 6:33 PM
This revision is now accepted and ready to land.Jun 12 2019, 6:33 PM
This revision was automatically updated to reflect the committed changes.