After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 646644 - gimp should use XDG cache dir for thumbnails
gimp should use XDG cache dir for thumbnails
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
git master
Other All
: Normal minor
: 2.10
Assigned To: Jehan
GIMP Bugs
: 675172 (view as bug list)
Depends on: 646508
Blocks: 523057
 
 
Reported: 2011-04-03 18:50 UTC by William Jon McCann
Modified: 2014-08-26 08:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Support of freedesktop thumbnails standard. (1017 bytes, patch)
2013-04-28 00:03 UTC, Jehan
none Details | Review

Description William Jon McCann 2011-04-03 18:50:01 UTC
Hopefully we'll be updating the thumbnails spec to follow the XDG Basedir spec.  And when we do it would be good for gimp to follow that.

Also see bug 646508.
Comment 1 Michael Natterer 2011-04-03 19:07:10 UTC
Great news, we will happily do so. When you update the spec, can
you take care of having a utility function added to glib that returns
the right folder, also on windows and on osx?
Comment 2 William Jon McCann 2011-04-03 19:13:40 UTC
http://library.gnome.org/devel/glib/2.28/glib-Miscellaneous-Utility-Functions.html#g-get-user-cache-dir

But yeah we need to state in the spec that we should be using this instead of home.
Comment 3 Michael Natterer 2011-04-03 20:12:41 UTC
Yeah my comment was not quite right, we would use the functions if they
did the right thing on all platforms.
Comment 4 Michael Natterer 2011-04-03 20:14:54 UTC
Also, there should probably be functions like

g_get_user_foo_dir_for_application (const gchar *application);

because otherwise the application would again need code in order
to *not* prepend a dot to the directory name on platforms which
don't normally use them.
Comment 5 William Jon McCann 2011-04-03 20:20:32 UTC
You shouldn't use the dot in the xdg dirs actually.
Comment 6 Michael Natterer 2011-04-03 20:39:46 UTC
Hm, how obvious. So ignore my last comment :)
Comment 7 William Jon McCann 2012-05-08 00:20:09 UTC
*** Bug 675172 has been marked as a duplicate of this bug. ***
Comment 8 Michael Natterer 2012-05-08 10:21:08 UTC
William, the issue of the subdir name again :)

In bug #675172 you say $XDG_CACHE_HOME/thumbnails

which would be ~/Library/Caches/thumbnails on a mac

When I look in there, I wonder if it wouldn't make more sense
to use something like ~/Library/Caches/org.freedesktop.thumbnails
on a mac.

This is probably too much to be asked from each app, can't we have
API in glib that does all that platform magic?

g_get_user_thumbnail_dir() for example?
Comment 9 Jens Georg 2012-05-08 10:26:32 UTC
g_get_user_cache_dir (used to) return %USERDIR%/Temporary Internet Files which is likely to be cleaned quite often unconditionally by most of those "windows optimizer" tools. It might make sense to either redefine the cache or not use the cache dir on windows.
Comment 10 Emmanuele Bassi (:ebassi) 2012-05-08 10:41:29 UTC
I'm not sure we need a public entry point for reading thumbnails; in theory, we just need to modify the path pointed by the G_FILE_ATTRIBUTE_THUMBNAIL, so that GFileInfo will give you a path you can open either for reading or for writing a thumbnail.
Comment 11 Dieter Verfaillie 2012-05-08 10:44:34 UTC
(In reply to comment #8)
> William, the issue of the subdir name again :)
> 
> In bug #675172 you say $XDG_CACHE_HOME/thumbnails
> 
> which would be ~/Library/Caches/thumbnails on a mac
> 
> When I look in there, I wonder if it wouldn't make more sense
> to use something like ~/Library/Caches/org.freedesktop.thumbnails
> on a mac.

g_get_user_cache_dir()/Freedesktop/Thumbnails would make sense
on win32, blending in with what's usually done...

(In reply to comment #9)
> g_get_user_cache_dir (used to) return %USERDIR%/Temporary Internet Files which
> is likely to be cleaned quite often unconditionally by most of those "windows
> optimizer" tools. It might make sense to either redefine the cache or not use
> the cache dir on windows.

... provided bug #659349 is fixed first (I've mentioned the branch
I've been working on over there).
Comment 12 Michael Natterer 2012-05-08 10:53:23 UTC
(In reply to comment #10)
> I'm not sure we need a public entry point for reading thumbnails; in theory, we
> just need to modify the path pointed by the G_FILE_ATTRIBUTE_THUMBNAIL, so that
> GFileInfo will give you a path you can open either for reading or for writing a
> thumbnail.

The problem here is that we'd need a way to pick the right subdir for
the thumbnail, so small, normal, large or fail/gimp-x.y. I don't think
the file attribute covers this.
Comment 13 Michael Natterer 2012-05-12 12:47:07 UTC
For the record, in the absence of a working g_get_user_cache_dir() for
all platforms, and the absence of a default location for thumbnails
on all platforms, I made the following change for OSX now:

commit 46127dc789762b5ac1b614f7399f5f610394be72
Author: Michael Natterer <mitch@gimp.org>
Date:   Sat May 12 14:39:44 2012 +0200

    Move gimpdir and thumbnails to proper places on OSX
    
    gimpdir goes to ~/Library/Gimp/x.y
    thumbnails go to ~/Library/Caches/org.freedesktop.thumbnails
    
    The thumbnail location is not standardized yet, but is the only
    location that makes sense. Also fix user install to search old
    gimpdirs to migrate in both Library and the classic location.
    Remove the obsolete CABON_CFLAGS from all makefiles.
    (cherry picked from commit 9112d68488f44408774f571e7d8fb48e41402674)

I'm simply assuming that the thumbnail spec will pick the same folder,
because it's the only one that makes sense on OSX.
Comment 14 Vincent Untz 2012-05-14 12:43:46 UTC
For reference, I think we should simply fix glib to use ~/Library/Cache/org.freedesktop/ for g_get_user_cache() on OSX.
Comment 15 Michael Natterer 2012-05-27 22:10:19 UTC
Um, absolutely not :) *Thumnails* should go into
~/Library/Cache/org.freedesktop.thumbnails, other *application*
specific stuff would go into ~/Library/Cache/GIMP for example.

I think this needs to be specified properly in the thumbnail spec,

g_get_user_cache() should just return ~/Library/Cache.
Comment 17 Michael Natterer 2012-12-01 14:22:50 UTC
We already moved gimpdir to .config/GIMP in git master.
Comment 18 Jehan 2013-04-28 00:02:28 UTC
I had a look at our current implementation. Looks like we were already doing most of the standard, with a specific subdirectory structure, and images of the standard size, etc. (cf. http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html)

Only the root directory was wrong. So that's easy to fix by using g_get_user_cache_dir () which will return the correct XDG_CACHE_HOME.

Now I did not touch the special code for OSX (~/Library/Cache/org.freedesktop.thumbnails). I don't know about it, if you say there is a good reason to use this folder, that's ok with me. :-)

As for Windows, I did not make any kind of special case, and g_get_user_cache_dir () returns CSIDL_INTERNET_CACHE on this platform. I read above that some people think it is not an optimal directory, and such. I personally have no opinion about this platform so I let it as is. I can do a special case code for Windows, as I did for the config directory too, if Mitch maybe really sees it fit? I really don't care much.
Comment 19 Jehan 2013-04-28 00:03:31 UTC
Created attachment 242692 [details] [review]
Support of freedesktop thumbnails standard.
Comment 20 Michael Natterer 2013-04-28 19:55:03 UTC
Yeah this bug was sitting here until some day applications have really
moved to use that folder. The patch is of course correct.

On my system, not a single app has started to use ~/.cache/thumbnails,
but debian unstable is stuck with gnome 3.4.

Is it really time to apply this patch?
Comment 21 Jehan 2013-04-28 20:08:12 UTC
Well on my system as well, there was not such directory until I tested GIMP.
But should we wait until we are the bad student? We can as well be the good student for once and do something first. :-)

Unless this standard is still considered unstable and the directory might change or something? It does not look like so to me, but I am not involved in the making of this spec, so I don't know…
Comment 22 Jehan 2013-05-08 14:47:32 UTC
Hey Mitch,

I took 10 minutes to search what other projects are moving to the XDG thumbnail spec. Well even though KDE has not updated this yet apparently (I have opened a ticket in their tracker for this), it looks like at least the GNOME desktop did the move last year:
See commit https://git.gnome.org/browse/gnome-desktop/commit/?id=22582a4ba4de44af8b0ea195f9896715fa8ac75d
and associated bug report: https://bugzilla.gnome.org/show_bug.cgi?id=646508

So indeed not many projects are already using this spec in currently released version, but it looks like it may happen as next versions will be released.
I guess we should do it in GIMP too. Moreover we are hosted as a GNOME project and the GNOME desktop has already done the change! :-)
Comment 23 Michael Natterer 2013-05-09 19:09:23 UTC
Thanks for checking. It seems it's about time :) Go ahead and push
the patch.

Maybe we should advise people to symlink ~/.thumbnails
or ~/.cache/thumbnails manually so they can share them
with older software like GIMP 2.8.
Comment 24 Jehan 2013-05-09 22:58:36 UTC
commit 483505f2fcc5546f246f62c590bd5b4871b3081e
Author: Jehan <jehan@girinstud.io>
Date:   Sun Apr 28 08:47:41 2013 +0900

    Bug 646644: support of freedesktop's Thumbnail Management Standard.