[evolution-exchange] Bug #632669 - Crash when path for attachments doesn't exist
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-exchange] Bug #632669 - Crash when path for attachments doesn't exist
- Date: Fri, 5 Nov 2010 18:16:12 +0000 (UTC)
commit 94728ba544f9f7993439434efcfa5675a6124b3b
Author: Milan Crha <mcrha redhat com>
Date: Fri Nov 5 19:15:10 2010 +0100
Bug #632669 - Crash when path for attachments doesn't exist
calendar/e-cal-backend-exchange.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/calendar/e-cal-backend-exchange.c b/calendar/e-cal-backend-exchange.c
index ad75d18..d26cf03 100644
--- a/calendar/e-cal-backend-exchange.c
+++ b/calendar/e-cal-backend-exchange.c
@@ -204,12 +204,33 @@ load_cache (ECalBackendExchange *cbex, E2kUri *e2kuri, GError **perror)
if (g_lstat (cbex->priv->local_attachment_store , &buf) < 0) {
#ifdef G_OS_UNIX
+ gint failed = TRUE;
+
+ again:
if (symlink (storage_dir, cbex->priv->local_attachment_store) < 0)
g_warning ("%s: symlink() failed: %s", G_STRFUNC, g_strerror (errno));
+ else
+ failed = FALSE;
+
+ if (failed) {
+ gchar *parent_dir = g_build_filename (user_cache_dir, "calendar", NULL);
+
+ if (!g_file_test (parent_dir, G_FILE_TEST_IS_DIR)) {
+ g_mkdir_with_parents (parent_dir, 0700);
+ g_free (parent_dir);
+
+ failed = FALSE;
+ goto again;
+ }
+
+ g_free (parent_dir);
+ }
#else
g_warning ("should symlink %s->%s, huh?",
cbex->priv->local_attachment_store,
storage_dir);
+
+ g_mkdir_with_parents (cbex->priv->local_attachment_store, 0700);
#endif
}
g_free (storage_dir);
@@ -1734,6 +1755,10 @@ save_attach_file (const gchar *dest_file, gchar *file_contents, gint len)
end :
close (fd);
+
+ if (!dest_url)
+ g_warning ("Failed to save attachment to file '%s', directory does not exist/disk full?", dest_file);
+
return dest_url;
}
@@ -1779,8 +1804,11 @@ get_attachment (ECalBackendExchange *cbex, const gchar *uid,
attach_file_url = save_attach_file (attach_file, (gchar *) attach_data, byte_array->len);
g_free (attach_data);
g_free (attach_file);
- d(printf ("attach file name : %s\n", attach_file_url));
- list = g_slist_append (list, attach_file_url);
+
+ if (attach_file_url) {
+ d(printf ("attach file name : %s\n", attach_file_url));
+ list = g_slist_append (list, attach_file_url);
+ }
g_object_unref (stream);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]