Bug 319528 - KDE should use the XDG "Thumbnail Managing Standard"
Summary: KDE should use the XDG "Thumbnail Managing Standard"
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: thumbnail (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Mark
URL: http://specifications.freedesktop.org...
Keywords:
Depends on:
Blocks: 337029
  Show dependency treegraph
 
Reported: 2013-05-08 14:43 UTC by Jehan
Modified: 2014-07-20 20:07 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jehan 2013-05-08 14:43:16 UTC
I have not tested the development version, nor checked the code, but on my stable KDE (4.8.5), it appears that KDE stores thumbnails under $HOME/.thumbnails, confirmed by this page documentation: http://techbase.kde.org/KDE_System_Administration/XDG_Filesystem_Hierarchy#Thumbnails
And I can't see any closed nor opened bug tickets about changing this, so I assume this must still be the case on dev version.

Now there is this standard to store the thumbnails under the XDG cache dir, which makes sense and tidy up the home directory: http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html

GNOME has already changed this for instance: https://git.gnome.org/browse/gnome-desktop/commit/?id=22582a4ba4de44af8b0ea195f9896715fa8ac75d
And we are discussing doing the change in GIMP too for instance.
Would be awesome if KDE desktop (and any other program using the old convention in general) could do the update too! :-)
Thanks!

Reproducible: Always

Steps to Reproduce:
1. Delete/rename the folder $HOME/.thumbnails if existing
2. Use a KDE software which creates and store image thumbnails (dolphin file manager for instance) and see a folder with image preview.
Actual Results:  
The ~/.thumbnails/ directory will be created and filled.

Expected Results:  
I would expect these previews to be generated in ~/.cache/thumbnails/ instead.
Comment 1 Mark 2013-06-27 22:21:31 UTC
Thank you for your report.

I see a couple of issues with this request.

First and for most, KIO is not the place that decides where thumbnails are stored. That is in the application's hands. So for that one alone i'd recommend you to try and ask the apps that actually make the thumbnails (dolphin, gwenview, ...)

Second, that spec is kinda enforcing when it comes to thumbnail image format. It enforces png. Png is a fine image codec, but better (which are faster and smaller) are popping up. Webp is such a codec along with the in house kde developed codec: "ez".

Third, kde has it's own image caching mechanism for thumbnails that most other kde apps are using as well. That is the "KImageCache" class if i'm not mistaken. So you don't need to worry much about double thumbnails.

Good luck!
Closing this one since it's not up to kio where the thumbnails go.
Comment 2 Christoph Feck 2013-06-27 22:53:20 UTC
Mark, even if KDE does not save thumbnails to ~/.cache/thumbnails, it should at least try reading from this location to show thumbnails generated by other applications.
Comment 3 Mark 2013-06-27 23:09:35 UTC
(In reply to comment #2)
> Mark, even if KDE does not save thumbnails to ~/.cache/thumbnails, it should
> at least try reading from this location to show thumbnails generated by
> other applications.

Hi Christopher,

That's true as well, but where should that be done? In the end application or in kimagecache?

BTW. How is EZ progressing?

Regards,
Mark
Comment 4 Christoph Feck 2013-06-28 00:49:08 UTC
Are you confusing KImageCache and thumbnail cache? They are unrelated, and that's why I consider this feature request valid.

And unless you are willing to discuss format changes with the X Desktop Group, we should respect that it mandates PNG files.

> How is EZ progressing?

If you mean IZ, no public commits since its announcement, due to lack of interest. I had hoped to attract digikam or Krita developers.
Comment 5 Mark 2013-06-28 14:00:03 UTC
(In reply to comment #4)
> Are you confusing KImageCache and thumbnail cache? They are unrelated, and
> that's why I consider this feature request valid.

Oke, seems i was mixing things up quite massively. I completely mis-read the bug report (i blame my ipad :p) The reporter was right and i was wrong.

KImageCache is indeed not used for thumbnails. Rather it's used for icon caching.

But this did left me wondering: "Where are those thumbnails being generated at the moment?" Since dolphin isn't doing that on it's own: http://quickgit.kde.org/?p=kde-baseapps.git&a=blob&h=eaaab6bc0529f1f72a2bc81ea3b1cd3729f8280b&hb=cab86c292b530ae52c504124e9c77af96cef7f01&f=dolphin%2Fsrc%2Fkitemviews%2Fkfileitemmodelrolesupdater.cpp the only caching it seems to rely upon is the PreviewJob cache.

So upon further investigation in PreviewJob it quickly became clear to me that PreviewJob is managing this. Only not in the .cache folder.

So my earlier statement that KIO is not the place to decide this is false since PreviewJob is doing this.
Also for my own question where this should be done.. PreiewJob apparently ;)

To conclude:
Currently: ~/.thumbnails is used
Needs to be: ~/.cache/thumbnails

Obviously changing bug report from wontfix to verified and remind. I will take care of this issue now. I have the tendency to forget bug reports so if you don't see progress within ~2 weeks, please do remind me! :)

It seems as simple as changing:
    d->thumbRoot = QDir::homePath() + QLatin1String("/.thumbnails/");
to:
    d->thumbRoot = QDir::homePath() + QLatin1String("/.cache/thumbnails/");

> 
> And unless you are willing to discuss format changes with the X Desktop
> Group, we should respect that it mandates PNG files.
> 
> > How is EZ progressing?
> 
> If you mean IZ, no public commits since its announcement, due to lack of
> interest. I had hoped to attract digikam or Krita developers.

Yet another thing i mixed up :( i meant IZ indeed. I hope the interest gets back in that project since it seems very promising!
Comment 6 Christoph Feck 2013-06-28 14:57:28 UTC
> Needs to be: ~/.cache/thumbnails

I hope you don't just change it to ~/.cache/thumbnails. If it was that simple, I had changed it right away :)

First read http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#DIRECTORY to understand what you are doing.

Then check if there is a Qt or KDE way to get the $XDG_CACHE_HOME directory. I know there is.

Additionally, it should be discussed if there should be done something to move the old contents over to the new directory, or at least if the old directory should be cleared or even removed. Check how GNOME did the migration.

Thanks for looking at this.
Comment 7 Mark 2013-06-28 16:17:49 UTC
(In reply to comment #6)
> > Needs to be: ~/.cache/thumbnails
> 
> I hope you don't just change it to ~/.cache/thumbnails. If it was that
> simple, I had changed it right away :)
> 
Yeah, i wasn't expecting it to be that easy :)
Comment 8 Maarten De Meyer 2013-08-11 15:32:32 UTC
I'm sorry, I made a patch for this bug 3 months ago but I forgot to post the link to the review request here.
https://git.reviewboard.kde.org/r/110388/

It's a very trivial patch, but I still want a review because this might cause hidden breakage.
And with everybody focusing on frameworks there has been no response yet.

Sorry for the duplicated effort.
Comment 9 Mark 2013-08-11 18:51:54 UTC
I guess i'm happy i forgot about this bug then :) No wasted duplicated effort.
Comment 10 Jehan 2013-12-21 00:07:00 UTC
Hi,

I was wondering how this report was going. I did not actually test it, but from a basic review of Maarten De Meyer's patch, it looks good to me. Well at least if "cacheDir.isEmpty()" means that the environment variable (here $XDG_CACHE_HOME) "is either not set or empty", which I guess it does. :-) Though if KDE/QT had a more high level way to get the XDG cache home (glib for instance has the function g_get_user_cache_dir(), so that programs don't have to redo the environment variable test logics themselves each and every time), it would be nicer. Is there no equivalent function?

As for doing something with the old contents, I'd say that no program can know if another program is still using it. So deleting/moving the old contents is counter-productive if you lose all the thumbnails for a third party, which will have to create again this old directory and all its future thumbnails. That's mostly to users to delete it manually and explicitly. Maybe what could be done though is to move old contents, then transform the empty old $HOME/.thumbnails into a symbolic link to $XDG_CACHE_HOME/thumbnails. This would avoid contents duplication, but has a drawback: if the user were to change its $XDG_CACHE_HOME and move all contents, the old directory would become a broken link, which at best would redo the contents duplication issue, and at worst would prevent some programs from creating thumbnails (because they can't create them into a broken link, and if they don't force the overwrite, they may not be able to recreate the old directory). So I'd say that even this should be up to the knowledgeable user to set up.
Comment 11 Maarten De Meyer 2013-12-21 13:24:26 UTC
> Though if KDE/QT had a more high level way to get the XDG cache home (glib
> for instance has the function g_get_user_cache_dir(), so that programs don't
> have to redo the environment variable test logics themselves each and every
> time), it would be nicer. Is there no equivalent function?

There is for Qt5:
http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html#standardLocations

I always planned to write a similar patch for frameworks using qstandardpaths. But since the other change never shipped I haven't gotten to it yet.
Thank you for reminding me.
Comment 12 Maarten De Meyer 2014-01-11 15:14:39 UTC
Small update:
While planning to make a patch for frameworks I found it's already done. Awesome!
It's a bit of a hassle to find the commit in the new git repo but the code is there.

From my point of view this bug is fixed. I see no reason to backport this.

ps Bug triagers, what is the workflow for bugs that are only fixed in frameworks? Do we keep them around?