[libgweather] GWeatherInfo: survive without a cache dir
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather] GWeatherInfo: survive without a cache dir
- Date: Thu, 22 Dec 2016 15:58:18 +0000 (UTC)
commit 76436628aa8777853c20bf85c354d891120dd163
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Thu Dec 22 16:56:24 2016 +0100
GWeatherInfo: survive without a cache dir
I'd argue that a missing/unwritable XDG_CACHE_HOME is a broken setup,
but people use that anyway, so let's warn and survive instead of
crashing.
https://bugzilla.gnome.org/show_bug.cgi?id=770979
libgweather/gweather-weather.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c
index b940276..500cf49 100644
--- a/libgweather/gweather-weather.c
+++ b/libgweather/gweather-weather.c
@@ -29,6 +29,7 @@
#include <time.h>
#include <unistd.h>
#include <langinfo.h>
+#include <errno.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -472,6 +473,7 @@ get_cache (void)
"libgweather", NULL);
if (g_mkdir_with_parents (filename, 0700) < 0) {
+ g_warning ("Failed to create libgweather cache directory: %s. Check your XDG_CACHE_HOME setting!",
strerror (errno));
g_free (filename);
return NULL;
}
@@ -505,12 +507,14 @@ ref_session (void)
session = soup_session_new ();
cache = get_cache ();
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (cache));
- g_object_set_data_full (G_OBJECT (session), "libgweather-cache", g_object_ref (cache),
- (GDestroyNotify) dump_and_unref_cache);
+ if (cache != NULL) {
+ soup_session_add_feature (session, SOUP_SESSION_FEATURE (cache));
+ g_object_set_data_full (G_OBJECT (session), "libgweather-cache", g_object_ref (cache),
+ (GDestroyNotify) dump_and_unref_cache);
- soup_cache_load (cache);
- g_object_unref (cache);
+ soup_cache_load (cache);
+ g_object_unref (cache);
+ }
static_session = session;
g_object_add_weak_pointer (G_OBJECT (session), (void**) &static_session);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]