Bug 452048 - Remote File Previews are not shown when Limit is set to 4096MiB or more
Summary: Remote File Previews are not shown when Limit is set to 4096MiB or more
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-29 19:32 UTC by brainpower
Modified: 2022-04-01 18:59 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.93


Attachments
path to fix the issue (1.80 KB, patch)
2022-03-29 19:32 UTC, brainpower
Details

Note You need to log in before you can comment on or make changes to this bug.
Description brainpower 2022-03-29 19:32:21 UTC
Created attachment 147826 [details]
path to fix the issue

SUMMARY

I noticed that dolphin did not show previews of videos on my nfs filesystem anymore
since one of the latest updates, probably Frameworks 5.92.

STEPS TO REPRODUCE
1. Set remote file preview limit to 4096 MiB or more in dolphin settings (General -> Previews)
2. Navigate to a remote FS with previewable files, nfs with video files in my case

OBSERVED RESULT

No previews. Even for files smaller than 4 GiB, 1.3 GiB video files for example.

EXPECTED RESULT

Previews being loaded or generated and shown, if the file is smaller than 4 GiB (or however the limit is set).

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
Dolphin Version: 22.03.80 (also tried git master)
KDE Frameworks Version: 5.92.0 (also tried git master)
Qt Version: 5.15.3
Kernel Version: 5.17.0-arch1-1 (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION

I traced this setting to ~/.config/kdeglobals where it is stored as MaximumRemoteSize in Group "PreviewSettings".
When set to 4096 MiB in dolphin, the value in the config file becomes 4294967296 .
When set to 4095 MiB, the value becomes 4293918720 .
This number looked suspiciously like UINT_MAX, so I looked that up: 4294967295
And behold, 4294967296 == UINT_MAX + 1.
So I went searching for the place where some code uses an uint instead of a size_t or something like that.

I compiled from source, did some "printf-Debugging" in previewjob.cpp [1]
and found that the "MaximumRemoteSize" setting was indeed not read correctly.
[1]: https://invent.kde.org/frameworks/kio/-/blob/a474739fc0eb714ac5230514f2af5ab397c1613a/src/widgets/previewjob.cpp#L415

MaximumRemoteSize=4293918720 (4095 MiB) was read as 18446744073708503040
MaximumRemoteSize=4294967296 (4096 MiB) was read as 0
MaximumRemoteSize=4296015872 (4097 MiB) was read as 1048576

I'm not sure which kind of combination of overflowing and/or misinterpreting would produce these values.
4293918720 does not even overflow an uint but produces a garbage 64 bit value somehow.
Anyway, indicating the correct integer type to KConfig's readEntry() by casting the default value seems to be enough to solve this.

I've attached a git format-patch which does that.
I wanted to do a Merge Request directly, but Gitlab refuses to let me fork KIO.
When trying to do that manually, it shows these errors from the remote's pre-receive hook:

```
[...]
remote: Resolving deltas: 100% (42286/42286), done.
remote: Audit failure - Commit d2aeab0987959fe3f250a2b0afa866215f82f94a - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit d2aeab0987959fe3f250a2b0afa866215f82f94a - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit c5e008e1af7a0cd7f4ca1acada4131443c468478 - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit c5e008e1af7a0cd7f4ca1acada4131443c468478 - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit c09634935294dbdea0839541bb620254581b5b65 - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit c09634935294dbdea0839541bb620254581b5b65 - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit ba6dd58ae76903c1802d8ee80cb4711abc5ef79f - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit ba6dd58ae76903c1802d8ee80cb4711abc5ef79f - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit fdba4bb168b64c3a9c89c62ace088bf19a7bced6 - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit fdba4bb168b64c3a9c89c62ace088bf19a7bced6 - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit 872a8be0e64225b39629514c475b93d9b14649d9 - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit 872a8be0e64225b39629514c475b93d9b14649d9 - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit 9063654daa5af4e3c846db9488c202cf3313a536 - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Audit failure - Commit 9063654daa5af4e3c846db9488c202cf3313a536 - Email address has an invalid domain : kde@randomguy3.me.uk
remote: Push declined - commits failed audit
remote: Should the audit failures above mention issues regarding your name, please ensure that your Git username has been set to your full name.
remote: Please see https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup for more details on ensuring Git has been fully configured.
remote: In the event that your full name has been set and is shown above as being rejected, please file a Sysadmin ticket at https://go.kde.org/systickets
To invent.kde.org:brainpower/kio.git
 ! [remote rejected]     fix-reading-maximumremotesize -> fix-reading-maximumremotesize (pre-receive hook declined)
```
No idea where to report this, though.
Comment 1 Ahmad Samir 2022-03-31 15:11:37 UTC
Good catch. I don't think it's a bug in QVariant or KConfig; AFAICS, the deduced template type is int, and the value is to big for an int (KIO::filesize_t is usigned long long), so QVariant returns 0 (I couldn't follow the code to verify this, I got lost in the forest of templates in QVariant).

The correct fix is indeed passing the correct type to readEntry() to get the correct type back.

About the issue you got, I'll tell Sysadmin team, hopefully they can help you with that issue.
Comment 2 brainpower 2022-03-31 16:54:24 UTC
I was able to fork and create a MR now, so here it is:
https://invent.kde.org/frameworks/kio/-/merge_requests/800
Comment 3 Nate Graham 2022-04-01 18:59:11 UTC
That was merged!