Handle tmp folder as midori_view_get_tmp_dir

This commit is contained in:
Christian Dywan 2012-07-08 23:03:47 +02:00
parent f9005c63a7
commit c4791e4a9a
3 changed files with 14 additions and 11 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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__ */