From 6442b34b8946f49a26184215abe8c2fb96f2879f Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sat, 8 May 2010 23:42:49 +0200 Subject: [PATCH] Use the basename of the suggested download name Sometimes the suggested name contains a folder name. --- midori/midori-browser.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 28936a9d..95463255 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1590,6 +1590,8 @@ midori_view_download_requested_cb (GtkWidget* view, } else { + const gchar* suggested; + gchar* basename; gchar* filename; gchar* uri; @@ -1597,8 +1599,11 @@ midori_view_download_requested_cb (GtkWidget* view, folder = g_strdup (g_get_tmp_dir ()); else folder = katze_object_get_string (browser->settings, "download-folder"); - filename = g_build_filename (folder, - webkit_download_get_suggested_filename (download), NULL); + suggested = webkit_download_get_suggested_filename (download); + /* The suggested name may contain a folder name */ + basename = g_path_get_basename (suggested); + filename = g_build_filename (folder, basename, NULL); + g_free (basename); /* If the filename exists, choose a different name */ if (g_access (filename, F_OK) == 0) {