From c4791e4a9a344afad7d97a739d9ec2e6bff910bf Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 8 Jul 2012 23:03:47 +0200 Subject: [PATCH] Handle tmp folder as midori_view_get_tmp_dir --- midori/midori-browser.c | 10 +--------- midori/midori-view.c | 12 ++++++++++-- midori/midori-view.h | 3 +++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index e765cdec..35ff6590 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1385,27 +1385,19 @@ midori_browser_download_prepare_destination_uri (WebKitDownload* download, gchar* download_dir = NULL; gchar* destination_uri; gchar* destination_filename; - gchar* midori_tmp_dir; suggested_filename = sokoke_get_download_filename (download); file_source = g_file_new_for_uri (suggested_filename); g_free (suggested_filename); file_basename = g_file_get_basename (file_source); if (folder == NULL) - { - midori_tmp_dir = g_strconcat ("midori-", g_get_user_name (), NULL); - download_dir = g_build_filename (g_get_tmp_dir (), midori_tmp_dir, NULL); - g_free (midori_tmp_dir); - } + download_dir = midori_view_get_tmp_dir (); else download_dir = (gchar*)folder; destination_filename = g_build_filename (download_dir, file_basename, NULL); destination_filename = midori_browser_download_prepare_filename (destination_filename); destination_uri = g_filename_to_uri (destination_filename, NULL, NULL); - if (!g_file_test (download_dir, G_FILE_TEST_EXISTS)) - katze_mkdir_with_parents (download_dir, 0700); - g_free (file_basename); if (folder == NULL) g_free (download_dir); diff --git a/midori/midori-view.c b/midori/midori-view.c index bbdbf090..898d321a 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -5422,6 +5422,15 @@ midori_view_fallback_extension (MidoriView* view, return ""; } +gchar* +midori_view_get_tmp_dir (void) +{ + gchar* tmpdir = g_strdup_printf ("%s/midori-%s", + g_get_tmp_dir (), g_get_user_name ()); + g_mkdir (tmpdir, 0700); + return tmpdir; +} + /** * midori_view_save_source: * @view: a #MidoriView @@ -5457,8 +5466,7 @@ midori_view_save_source (MidoriView* view, if (!outfile) { gchar* extension = midori_view_get_uri_extension (uri); - gchar* tmpdir = g_strdup_printf ("%s/midori-%s", g_get_tmp_dir (), g_get_user_name ()); - g_mkdir (tmpdir, 0700); + gchar* tmpdir = midori_view_get_tmp_dir (); unique_filename = g_strdup_printf ("%s/%uXXXXXX%s", tmpdir, g_str_hash (uri), midori_view_fallback_extension (view, extension)); g_free (tmpdir); diff --git a/midori/midori-view.h b/midori/midori-view.h index 5b9dd3ef..3912f07d 100644 --- a/midori/midori-view.h +++ b/midori/midori-view.h @@ -289,6 +289,9 @@ const gchar* midori_view_fallback_extension (MidoriView* view, const gchar* extension); +gchar* +midori_view_get_tmp_dir (void); + G_END_DECLS #endif /* __MIDORI_VIEW_H__ */ -- 2.39.5