Bug 123458 - [GTK] Put cache files in XDG_CACHE_HOME
Summary: [GTK] Put cache files in XDG_CACHE_HOME
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: http://bugs.debian.org/cgi-bin/bugrep...
Depends on:
Reported: 2013-10-29 12:41 PDT by Emilio Pozuelo Monfort
Modified: 2014-01-24 12:01 PST (History)
5 users (show)

See Also:

Patch (4.99 KB, patch)
2013-12-12 01:41 PST, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (5.02 KB, patch)
2013-12-19 10:46 PST, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (4.80 KB, patch)
2013-12-20 01:24 PST, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (4.79 KB, patch)
2014-01-17 11:43 PST, Enrique Ocaña
no flags Details | Formatted Diff | Diff
Patch (4.78 KB, patch)
2014-01-24 11:06 PST, Enrique Ocaña
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Emilio Pozuelo Monfort 2013-10-29 12:41:47 PDT
It looks like webkit is placing some cache in ~/.local/share/webkit ($XDG_DATA_HOME). That should probably go in ~/.cache/webkit ($XDG_CACHE_HOME)
Comment 1 Enrique Ocaña 2013-12-12 00:39:11 PST
There are three places where XDG env vars are used:

WebKit/gtk/webkit/webkitapplicationcache.cpp: * $XDG_CACHE_HOME/webkitgtk/applications and cannot be modified.
WebKit/gtk/webkit/webkiticondatabase.cpp: * ~/.local/share/webkit/icondatabase, depending on XDG_DATA_HOME.
WebKit/gtk/webkit/webkitwebsettings.cpp:    * "enable-html5-local-storage". The default path is $XDG_DATA_HOME/webkit/databases/.

The icon database can be considered "cache". The HTML5 local storage can't, and sould remain where it is by default. However, it can be changed by the application via the "html5-local-storage-database-path" property in WebKitWebSettings.

I'm going to prepare a patch to change the icon database path.
Comment 2 Enrique Ocaña 2013-12-12 01:41:32 PST
Created attachment 219058 [details]
Comment 3 Enrique Ocaña 2013-12-12 01:47:54 PST
BTW, found more places where XDG_DATA_HOME is used, but they seem to be persistent data that shouldn't be moved to cache:

$ git grep g_get_user_data_dir
Source/WebKit/gtk/webkit/webkitglobals.cpp:    GOwnPtr<gchar> databaseDirectory(g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL));
Source/WebKit/gtk/webkit/webkitglobals.cpp:    GOwnPtr<gchar> iconDatabasePath(g_build_filename(g_get_user_data_dir(), "webkit", "icondatabase", NULL));
Source/WebKit/gtk/webkit/webkitwebsettings.cpp:    GOwnPtr<gchar> localStoragePath(g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL));
Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp: * default directory for the platform (see g_get_user_data_dir()).
Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp:    GOwnPtr<gchar> databaseDirectory(g_build_filename(g_get_user_data_dir(), "webkitgtk", "databases", NULL));
Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp:    GOwnPtr<gchar> databaseDirectory(g_build_filename(g_get_user_data_dir(), "webkitgtk", "icondatabase", NULL));
Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp:    GOwnPtr<gchar> storageDirectory(g_build_filename(g_get_user_data_dir(), "webkitgtk", "localstorage", NULL));
Tools/DumpRenderTree/gtk/DumpRenderTree.cpp:    GOwnPtr<gchar> localStoragePath(g_build_filename(g_get_user_data_dir(), "DumpRenderTreeGtk", "databases", NULL));
Tools/DumpRenderTree/gtk/DumpRenderTree.cpp:    GOwnPtr<char> fallback(g_build_filename(g_get_user_data_dir(), "gtkwebkitdrt", "databases", NULL));
Tools/GtkLauncher/main.c:    iconDatabasePath = g_build_filename(g_get_user_data_dir(), "webkit", "icondatabase", NULL);
Comment 4 Enrique Ocaña 2013-12-19 10:46:51 PST
Created attachment 219658 [details]
Comment 5 Sergio Villar Senin 2013-12-20 00:07:26 PST
Comment on attachment 219658 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=219658&action=review

The change looks good to me.

> Source/WebKit/gtk/ChangeLog:10
> +

The format of the ChangeLog is not correct. You have to use Tools/Scripts/prepare-Changelog to properly generate it.

> Source/WebKit2/ChangeLog:9
> +


> Tools/ChangeLog:9
> +

Comment 6 Enrique Ocaña 2013-12-20 01:23:35 PST
Thanks. The inclusion of the git log message confused me.
Comment 7 Enrique Ocaña 2013-12-20 01:24:04 PST
Created attachment 219740 [details]
Comment 8 Martin Robinson 2013-12-20 11:13:25 PST
Comment on attachment 219740 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=219740&action=review

Looks good, but a few small suggestions before landing this. You can just upload a new version with the Reviewed by line filled in and then I can commit it with the commit queue.

> Source/WebKit/gtk/ChangeLog:3
> +        https://bugs.webkit.org/show_bug.cgi?id=123458

This changelog is missing a newline.

> Source/WebKit2/ChangeLog:3
> +        [GTK] Put cache files in XDG_CACHE_HOME
> +        https://bugs.webkit.org/show_bug.cgi?id=123458

This one too.

> Tools/GtkLauncher/main.c:242
> -    iconDatabasePath = g_build_filename(g_get_user_data_dir(), "webkit", "icondatabase", NULL);
> +    iconDatabasePath = g_build_filename(g_get_user_cache_dir(), "webkit", "icondatabase", NULL);

It's probably a good moment to actually put this into a GtkLauncher subdirectory instead of "webkit"
Comment 9 Enrique Ocaña 2014-01-17 11:43:52 PST
Created attachment 221479 [details]
Comment 10 WebKit Commit Bot 2014-01-24 08:23:34 PST
Comment on attachment 221479 [details]

Rejecting attachment 221479 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.appspot.com', '--bot-id=webkit-cq-03', 'apply-attachment', '--no-update', '--non-interactive', 221479, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Last 500 characters of output:
patching file Source/WebKit/gtk/webkit/webkiticondatabase.cpp
patching file Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp
Hunk #1 FAILED at 122.
1 out of 1 hunk FAILED -- saving rejects to file Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp.rej
patching file Tools/ChangeLog
Hunk #1 succeeded at 1 with fuzz 3.
patching file Tools/GtkLauncher/main.c

Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

Full output: http://webkit-queues.appspot.com/results/6529999087599616
Comment 11 Enrique Ocaña 2014-01-24 11:06:53 PST
Created attachment 222120 [details]
Comment 12 WebKit Commit Bot 2014-01-24 12:01:54 PST
Comment on attachment 222120 [details]

Clearing flags on attachment: 222120

Committed r162714: <http://trac.webkit.org/changeset/162714>
Comment 13 WebKit Commit Bot 2014-01-24 12:01:57 PST
All reviewed patches have been landed.  Closing bug.