[Xfce4-commits] <midori:master> Introduce _for_reading versions for cache and data
Christian Dywan
noreply at xfce.org
Sun Sep 30 00:26:03 CEST 2012
Updating branch refs/heads/master
to 7c26d4ca116f856be92cda371482d5179b25f1be (commit)
from ea287a34ba7ec172928f8a413375b95e00d43e43 (commit)
commit 7c26d4ca116f856be92cda371482d5179b25f1be
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Sep 30 00:24:46 2012 +0200
Introduce _for_reading versions for cache and data
Move favicon setup out of full session since we currently
can't prevent it from creating the database file.
katze/katze-utils.c | 2 +-
katze/midori-hsts.vala | 10 +++++-----
katze/midori-paths.vala | 23 +++++++++++++++++++++--
midori/main.c | 16 +++++++---------
4 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/katze/katze-utils.c b/katze/katze-utils.c
index 9c5ef9c..4987a3a 100644
--- a/katze/katze-utils.c
+++ b/katze/katze-utils.c
@@ -1502,7 +1502,7 @@ katze_load_cached_icon (const gchar* uri,
filename = g_strdup_printf ("%s%s", checksum, ext ? ext : "");
g_free (icon_uri);
g_free (checksum);
- path = g_build_filename (midori_paths_get_cache_dir (), "icons", filename, NULL);
+ path = g_build_filename (midori_paths_get_cache_dir_for_reading (), "icons", filename, NULL);
g_free (filename);
if ((icon = gdk_pixbuf_new_from_file_at_size (path, 16, 16, NULL)))
{
diff --git a/katze/midori-hsts.vala b/katze/midori-hsts.vala
index a878a6e..4ceb174 100644
--- a/katze/midori-hsts.vala
+++ b/katze/midori-hsts.vala
@@ -39,15 +39,13 @@ namespace Midori {
}
}
- File file;
HashTable<string, Directive> whitelist;
bool debug = false;
- public HSTS (owned string filename) {
+ public HSTS () {
whitelist = new HashTable<string, Directive> (str_hash, str_equal);
read_cache (File.new_for_path (Paths.get_preset_filename (null, "hsts")));
- file = File.new_for_path (filename);
- read_cache (file);
+ read_cache (File.new_for_path (Paths.get_config_filename_for_reading ("hsts")));
if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "hsts") == 0)
debug = true;
}
@@ -111,13 +109,15 @@ namespace Midori {
if (Midori.Paths.is_readonly ())
return;
+ string filename = Paths.get_config_filename_for_writing ("hsts");
try {
+ var file = File.new_for_path (filename);
var stream = file.append_to/* FIXME _async*/ (FileCreateFlags.NONE);
yield stream.write_async ((host + " " + header + "\n").data);
yield stream.flush_async ();
}
catch (Error error) {
- critical ("Failed to update %s: %s", file.get_path (), error.message);
+ critical ("Failed to update %s: %s", filename, error.message);
}
}
diff --git a/katze/midori-paths.vala b/katze/midori-paths.vala
index 0792559..ce4c07d 100644
--- a/katze/midori-paths.vala
+++ b/katze/midori-paths.vala
@@ -38,7 +38,9 @@ namespace Midori {
static string? config_dir = null;
static string? readonly_dir = null;
static string? cache_dir = null;
+ static string? cache_dir_for_reading = null;
static string? user_data_dir = null;
+ static string? user_data_dir_for_reading = null;
static string? tmp_dir = null;
public static string get_config_dir_for_reading () {
@@ -76,6 +78,9 @@ namespace Midori {
else if (mode == RuntimeMode.PRIVATE || mode == RuntimeMode.APP) {
readonly_dir = config_base ?? Path.build_path (Path.DIR_SEPARATOR_S,
Environment.get_user_config_dir (), PACKAGE_NAME);
+ cache_dir_for_reading = Path.build_path (Path.DIR_SEPARATOR_S,
+ Environment.get_user_cache_dir (), PACKAGE_NAME);
+ user_data_dir_for_reading = Environment.get_user_data_dir ();
tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S,
Environment.get_tmp_dir (), "midori-" + Environment.get_user_name ());
}
@@ -118,6 +123,20 @@ namespace Midori {
return user_data_dir;
}
+ public static unowned string get_user_data_dir_for_reading () {
+ assert (user_data_dir_for_reading != null || user_data_dir != null);
+ if (user_data_dir != null)
+ return user_data_dir;
+ return user_data_dir_for_reading;
+ }
+
+ public static unowned string get_cache_dir_for_reading () {
+ assert (cache_dir_for_reading != null || cache_dir != null);
+ if (cache_dir != null)
+ return cache_dir;
+ return cache_dir_for_reading;
+ }
+
public static unowned string get_tmp_dir () {
assert (tmp_dir != null);
return tmp_dir;
@@ -213,7 +232,7 @@ namespace Midori {
#if HAVE_WIN32
return Path.build_filename (exec_path, "share", res1, res2, filename);
#else
- string path = Path.build_filename (get_user_data_dir (), res1, res2, filename);
+ string path = Path.build_filename (get_user_data_dir_for_reading (), res1, res2, filename);
if (Posix.access (path, Posix.F_OK) == 0)
return path;
@@ -229,7 +248,7 @@ namespace Midori {
/* returns the path to a file containing system default configuration */
public static string get_preset_filename (string? folder, string filename) {
- assert (config_dir != null);
+ assert (exec_path != null);
#if HAVE_WIN32
return Path.build_filename (exec_path, "etc", "xdg", PACKAGE_NAME, folder ?? "", filename);
diff --git a/midori/main.c b/midori/main.c
index 0b1897f..dabe6c8 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -1007,13 +1007,6 @@ midori_load_soup_session (gpointer settings)
G_CALLBACK (soup_session_settings_notify_first_party_cb), session);
#endif
- #if WEBKIT_CHECK_VERSION (1, 8, 0)
- gchar* cache = g_build_filename (midori_paths_get_user_data_dir (),
- "webkit", "icondatabase", NULL);
- webkit_favicon_database_set_path (webkit_get_favicon_database (), cache);
- g_free (cache);
- #endif
-
#if defined (HAVE_LIBSOUP_2_34_0)
g_signal_connect (session, "request-started",
G_CALLBACK (midori_soup_session_request_started_cb), session);
@@ -1021,8 +1014,7 @@ midori_load_soup_session (gpointer settings)
g_signal_connect (session, "request-queued",
G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings);
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (
- midori_hsts_new (midori_paths_get_config_filename_for_reading ("hsts"))));
+ soup_session_add_feature (session, SOUP_SESSION_FEATURE (midori_hsts_new ()));
midori_soup_session_debug (session);
@@ -1195,6 +1187,12 @@ midori_load_soup_session_full (gpointer settings)
katze_object_get_int (settings, "maximum-cache-size") * 1024 * 1024);
soup_cache_load (SOUP_CACHE (feature));
#endif
+
+ #if WEBKIT_CHECK_VERSION (1, 8, 0)
+ katze_assign (config_file, g_build_filename (midori_paths_get_user_data_dir (),
+ "webkit", "icondatabase", NULL));
+ webkit_favicon_database_set_path (webkit_get_favicon_database (), config_file);
+ #endif
g_free (config_file);
return FALSE;
More information about the Xfce4-commits
mailing list