Bug 507488

Summary: Folder thumbnails fail to generate on bcachefs file system
Product: [Frameworks and Libraries] frameworks-kio Reporter: Mikhail Morozov <wexo.hadujobo>
Component: generalAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: kdedev, kdelibs-bugs-null, wexo.hadujobo, windows2linux
Priority: NOR    
Version First Reported In: 6.16.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=507493
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Folder with and without a thumbnail

Description Mikhail Morozov 2025-07-25 19:30:08 UTC
Created attachment 183513 [details]
Folder with and without a thumbnail

SUMMARY
If a folder is situated on a bcachefs partition its icon in Dolphin will not display thumbnails of its contents regardless of the preview options.

STEPS TO REPRODUCE
1. Setup the environment.
> $ touch fs && truncate fs --size 128M && mkfs.bcachefs fs && sudo mount fs /mnt && sudo chown $USER:$USER /mnt && mkdir /mnt/folder && cp /usr/share/plasma/avatars/photos/Dog.png /mnt/folder/picture.png
2. Open the Dolphin file manager.
3. Enable previews for folders and pictures.
4. Open the `/mnt` directory.
Alternatively
2. Compile KIO with `cmake -DBUILD_TESTING=ON ...`
3. Run `build/bin/previewtest`
4. Select `/mnt/folder` and press `Generate`

OBSERVED RESULT
Icon of `/mnt/folder` keeps its stock appearance.
`build/bin/previewtest` displays `failed`.

EXPECTED RESULT
Folder `/mnt/folder` has on overlaid thumbnail of `/mnt/folder/picture.png` on its icon.
`build/bin/previewtest` displays an icon.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.4.3
KDE Frameworks Version: 6.16.0
Qt Version: 6.9.1
Kernel Version: 6.15.7-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 5600G with Radeon Graphics
Memory: 32 GiB of RAM (27.3 GiB usable)
Graphics Processor: AMD Radeon Graphics

ADDITIONAL INFORMATION
The cause of this bug is a file size check at https://invent.kde.org/frameworks/kio/-/blob/v6.16.0/src/gui/previewjob.cpp?ref_type=tags#L580
> const KIO::filesize_t size = static_cast<KIO::filesize_t>(statResult.numberValue(KIO::UDSEntry::UDS_SIZE, 0));
> if (size == 0) {
>     qCDebug(KIO_GUI) << "PreviewJob: skipping an empty file, migth be a broken symlink" << d->currentItem.item.url();
>     d->determineNextFile();
>     return;
> }
It seems on bcachefs stat'ing any folder results in the reported size always being 0.
> $ stat /mnt/folder
>   File: /mnt/folder
>   Size: 0               Blocks: 0          IO Block: 4096   directory
> Device: 253,0   Inode: 74608       Links: 2
> Access: (0755/drwxr-xr-x)  Uid: ( 1000/   user)   Gid: ( 1000/   group)
> Access: 2025-07-25 XX:XX:XX.XXXXXXXXX -XXXX
> Modify: 2025-07-25 XX:XX:XX.XXXXXXXXX +XXXX
> Change: 2025-07-25 XX:XX:XX.XXXXXXXXX -XXXX
>  Birth: 2025-07-25 XX:XX:XX.XXXXXXXXX +XXXX
Commenting out the above size check restores the folder thumbnails.

I have also checked and the bug is still present on the master branch (f60be14b9ed1b90273d1ef9e2ed145afdd3db6e9) in file https://invent.kde.org/frameworks/kio/-/blob/master/src/gui/filepreviewjob.cpp#L160
Comment 1 flan_suse 2025-08-17 14:30:40 UTC
Maybe it's related to this bug?

https://bugs.kde.org/show_bug.cgi?id=501882
Comment 2 flan_suse 2025-08-17 14:34:47 UTC
> It seems on bcachefs stat'ing any folder results in the reported size always being 0.

This seems to be true with folders on an SMB share (mounted with cifs).

I think you found the culprit why this affects SMB also. :)
Comment 3 flan_suse 2025-08-17 14:38:19 UTC
I believe since the bug is the same and the factors that determine it are the same (which affects SMB and bcachefs, and anywhere else that a folder's size is "0"), this can be marked as a duplicate of the bug from 5 months ago: https://bugs.kde.org/show_bug.cgi?id=501882
Comment 4 flan_suse 2025-08-18 01:01:37 UTC

*** This bug has been marked as a duplicate of bug 501882 ***
Comment 5 Mikhail Morozov 2025-09-23 16:49:22 UTC
Created a merge request at https://invent.kde.org/frameworks/kio/-/merge_requests/2004
Comment 6 Méven 2025-09-24 08:39:12 UTC
Git commit 8a713b01dd94027a8869b8dc417af162f61abac2 by Méven Car, on behalf of Mikhail Morozov.
Committed on 24/09/2025 at 08:39.
Pushed by meven into branch 'master'.

filepreviewjob: Don't apply size check to directories

If a folder is situated on a bcachefs partition (or any other directory with 0 sized directory entry) its icon in Dolphin will not display thumbnails of its contents regardless of the preview options.

Judging by the log line `"PreviewJob: skipping an empty file, migth be a broken symlink"`, the size check should only apply to files not folders.
Related: bug 501882

M  +2    -2    src/gui/filepreviewjob.cpp

https://invent.kde.org/frameworks/kio/-/commit/8a713b01dd94027a8869b8dc417af162f61abac2