aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--doc/reference/tmpl/ephy-embed.sgml2
-rw-r--r--embed/mozilla/MozDownload.cpp42
-rw-r--r--lib/ephy-file-helpers.c14
-rw-r--r--lib/ephy-file-helpers.h2
5 files changed, 44 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 665bad09a..8101a0aa0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2004-07-22 Marco Pesenti Gritti <marco@gnome.org>
+ * doc/reference/tmpl/ephy-embed.sgml:
+ * embed/mozilla/MozDownload.cpp:
+ * lib/ephy-file-helpers.c: (ephy_ensure_dir_exists):
+ * lib/ephy-file-helpers.h:
+
+ Handle the case where the downloads dir cannot be
+ created gracefully. Fix #146902
+
+2004-07-22 Marco Pesenti Gritti <marco@gnome.org>
+
* src/bookmarks/ephy-bookmarks-import.c:
(ephy_bookmarks_import_mozilla):
diff --git a/doc/reference/tmpl/ephy-embed.sgml b/doc/reference/tmpl/ephy-embed.sgml
index 787e143fb..83b60c806 100644
--- a/doc/reference/tmpl/ephy-embed.sgml
+++ b/doc/reference/tmpl/ephy-embed.sgml
@@ -128,6 +128,8 @@ be done by casting).
@:
@:
@:
+@:
+@:
@:
<!-- ##### SIGNAL EphyEmbed::ge-security-change ##### -->
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index 4b00d678b..f1e6713f3 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -581,44 +581,42 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI
static char*
GetFilePath (const char *filename)
{
- char *path = NULL;
- char *download_dir, *converted_dp, *expanded;
+ char *path = NULL, *download_dir, *expanded;
download_dir = eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR);
- if (!download_dir)
+ if (download_dir && strcmp (download_dir, "Downloads") == 0)
{
- /* Emergency download destination */
- return g_build_filename (g_get_home_dir (), filename, NULL);
+ g_free (download_dir);
+ download_dir = ephy_file_downloads_dir ();
}
-
- if (g_utf8_collate (download_dir, "Downloads") == 0)
+ else if (download_dir)
{
- const char *default_dir;
+ char *converted_dp;
+ converted_dp = g_filename_from_utf8 (download_dir, -1, NULL, NULL, NULL);
g_free (download_dir);
+ download_dir = converted_dp;
+ }
- default_dir = ephy_file_downloads_dir ();
- ephy_ensure_dir_exists (default_dir);
-
- return g_build_filename (default_dir, filename, NULL);
+ if (download_dir == NULL)
+ {
+ /* Emergency download destination */
+ download_dir = g_strdup (g_get_home_dir ());
}
- converted_dp = g_filename_from_utf8 (download_dir, -1, NULL, NULL, NULL);
- g_free (download_dir);
+ g_return_val_if_fail (download_dir != NULL, FALSE);
- if (converted_dp)
+ expanded = gnome_vfs_expand_initial_tilde (download_dir);
+ if (ephy_ensure_dir_exists (expanded))
{
- expanded = gnome_vfs_expand_initial_tilde (converted_dp);
- ephy_ensure_dir_exists (expanded);
path = g_build_filename (expanded, filename, NULL);
-
- g_free (expanded);
- g_free (converted_dp);
}
- else
+ g_free (expanded);
+ g_free (download_dir);
+
+ if (path == NULL)
{
- /* Fallback, see FIXME above too */
path = g_build_filename (g_get_home_dir (), filename, NULL);
}
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 5b8dbc323..138d8719f 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -224,17 +224,25 @@ ephy_file_helpers_shutdown (void)
dot_dir = NULL;
}
-void
+gboolean
ephy_ensure_dir_exists (const char *dir)
{
if (g_file_test (dir, G_FILE_TEST_IS_DIR) == FALSE)
{
if (g_file_test (dir, G_FILE_TEST_EXISTS) == TRUE)
- g_error (_("%s exists, please move it out of the way."), dir);
+ {
+ g_warning (_("%s exists, please move it out of the way."), dir);
+ return FALSE;
+ }
if (mkdir (dir, 488) != 0)
- g_error (_("Failed to create directory %s."), dir);
+ {
+ g_warning (_("Failed to create directory %s."), dir);
+ return FALSE;
+ }
}
+
+ return TRUE;
}
static void
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index d399b4a5a..bfb7e1b6c 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -40,7 +40,7 @@ const char *ephy_file_tmp_dir (void);
char *ephy_file_tmp_filename (const char *base,
const char *extension);
-void ephy_ensure_dir_exists (const char *dir);
+gboolean ephy_ensure_dir_exists (const char *dir);
GSList *ephy_file_find (const char *path,
const char *fname,