diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2004-07-22 17:17:09 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2004-07-22 17:17:09 +0800 |
commit | 8ed863129291204c3b293e41dae4bc3a1c7e9127 (patch) | |
tree | d68732b960661ad2a5a818320c02d946b8eeeae1 /embed/mozilla/MozDownload.cpp | |
parent | 561c5a9432b239aee5581ef83b0f38c5eeecd30c (diff) | |
download | gsoc2013-epiphany-8ed863129291204c3b293e41dae4bc3a1c7e9127.tar gsoc2013-epiphany-8ed863129291204c3b293e41dae4bc3a1c7e9127.tar.gz gsoc2013-epiphany-8ed863129291204c3b293e41dae4bc3a1c7e9127.tar.bz2 gsoc2013-epiphany-8ed863129291204c3b293e41dae4bc3a1c7e9127.tar.lz gsoc2013-epiphany-8ed863129291204c3b293e41dae4bc3a1c7e9127.tar.xz gsoc2013-epiphany-8ed863129291204c3b293e41dae4bc3a1c7e9127.tar.zst gsoc2013-epiphany-8ed863129291204c3b293e41dae4bc3a1c7e9127.zip |
Handle the case where the downloads dir cannot be created gracefully. Fix
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
Diffstat (limited to 'embed/mozilla/MozDownload.cpp')
-rw-r--r-- | embed/mozilla/MozDownload.cpp | 42 |
1 files changed, 20 insertions, 22 deletions
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); } |