Bug 457935

Summary: MIME type of some local file is never determined except when sorted by types
Product: [Applications] dolphin Reporter: MILAS Robin <milas.robin>
Component: generalAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: REPORTED ---    
Severity: normal CC: kfm-devel
Priority: NOR    
Version: 22.04.1   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Video where you can see that the preview work but does not show on the file
File properties

Description MILAS Robin 2022-08-16 01:20:38 UTC
Created attachment 151348 [details]
Video where you can see that the preview work but does not show on the file

ISO File does not show any preview while on the file

STEPS TO REPRODUCE
1. Clone and install https://github.com/Hinara/dolphin-retro-thumbnail (my thumbnailer)
2. Enable it and check that previews are enable for file of ~1.4GB
3. Try to preview a Gamecube iso file

OBSERVED RESULT
The file preview does not work but the parent folder preview of it inner file does work

EXPECTED RESULT
That the file preview works as well as 

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.24.4
KDE Frameworks Version:  5.96.0
Qt Version: 5.15.5
Comment 1 MILAS Robin 2022-08-16 17:41:40 UTC
Additional Information: It seems to be linked to a MIME-Type detection which partially fail !
Comment 2 MILAS Robin 2022-08-16 17:52:35 UTC
I don't see the issue content so I will add it back there.
I've got an issue with my custom thumbnailer. I checked it and my thumbnailer work and even produce thumbnail for the parent folder.
However, the preview of the file is not displayed on the file in question.
The file is a gamecube ISO file. It seems that dolphin use the generic ISO ("raw CD image" MIME:"application/x-cd-image") instead of its dedicated MIME: "application/x-gamecube-rom".
"xdg-mime query filetype" does correctly report the file as an "application/x-gamecube-rom".
Dolphin seems to inconsistently use both MIME as the preview work on the parent folder but not on the file in question as well as proposed programs are the one for "application/x-cd-image" ignoring totaly the "application/x-gamecube-rom"associated programs.
Comment 3 MILAS Robin 2022-08-16 17:57:02 UTC
Created attachment 151361 [details]
File properties

Type is set to "application/x-iso-image" as well as associated app 
"Content" field match "application/x-gamecube-image" but associated app are not even proposed nor the preview.
Comment 4 MILAS Robin 2022-08-17 02:43:32 UTC
So as far as I am it seems that KCoreDirLister emit items with incorrect mimetype (at least they do not check content, in some case).
Comment 5 MILAS Robin 2022-08-17 04:12:15 UTC
Ok so I finally found the cause.
This is due to KFileItemModel using setDelayedMimeTypes(true) on its KDirListener.
This means that the mimetype is determined by file extension EXCEPT when item are sorted by types.
Meaning that my preview does not work when files are sorted by names, but does display when files are sorted by types !!
I'm gonna take a look a bit latter to try to see where this can be fix.
There still be some other strange behaviour, which I think might be due to more time to execute full mime research on files when in a big folder because for a strange reason the preview and mimetype does work in my download folder without being sorted by types