Handle tmp folder as midori_view_get_tmp_dir
This commit is contained in:
parent
f9005c63a7
commit
c4791e4a9a
3 changed files with 14 additions and 11 deletions
|
@ -1385,27 +1385,19 @@ midori_browser_download_prepare_destination_uri (WebKitDownload* download,
|
||||||
gchar* download_dir = NULL;
|
gchar* download_dir = NULL;
|
||||||
gchar* destination_uri;
|
gchar* destination_uri;
|
||||||
gchar* destination_filename;
|
gchar* destination_filename;
|
||||||
gchar* midori_tmp_dir;
|
|
||||||
|
|
||||||
suggested_filename = sokoke_get_download_filename (download);
|
suggested_filename = sokoke_get_download_filename (download);
|
||||||
file_source = g_file_new_for_uri (suggested_filename);
|
file_source = g_file_new_for_uri (suggested_filename);
|
||||||
g_free (suggested_filename);
|
g_free (suggested_filename);
|
||||||
file_basename = g_file_get_basename (file_source);
|
file_basename = g_file_get_basename (file_source);
|
||||||
if (folder == NULL)
|
if (folder == NULL)
|
||||||
{
|
download_dir = midori_view_get_tmp_dir ();
|
||||||
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);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
download_dir = (gchar*)folder;
|
download_dir = (gchar*)folder;
|
||||||
destination_filename = g_build_filename (download_dir, file_basename, NULL);
|
destination_filename = g_build_filename (download_dir, file_basename, NULL);
|
||||||
destination_filename = midori_browser_download_prepare_filename (destination_filename);
|
destination_filename = midori_browser_download_prepare_filename (destination_filename);
|
||||||
destination_uri = g_filename_to_uri (destination_filename, NULL, NULL);
|
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);
|
g_free (file_basename);
|
||||||
if (folder == NULL)
|
if (folder == NULL)
|
||||||
g_free (download_dir);
|
g_free (download_dir);
|
||||||
|
|
|
@ -5422,6 +5422,15 @@ midori_view_fallback_extension (MidoriView* view,
|
||||||
return "";
|
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:
|
* midori_view_save_source:
|
||||||
* @view: a #MidoriView
|
* @view: a #MidoriView
|
||||||
|
@ -5457,8 +5466,7 @@ midori_view_save_source (MidoriView* view,
|
||||||
if (!outfile)
|
if (!outfile)
|
||||||
{
|
{
|
||||||
gchar* extension = midori_view_get_uri_extension (uri);
|
gchar* extension = midori_view_get_uri_extension (uri);
|
||||||
gchar* tmpdir = g_strdup_printf ("%s/midori-%s", g_get_tmp_dir (), g_get_user_name ());
|
gchar* tmpdir = midori_view_get_tmp_dir ();
|
||||||
g_mkdir (tmpdir, 0700);
|
|
||||||
unique_filename = g_strdup_printf ("%s/%uXXXXXX%s", tmpdir,
|
unique_filename = g_strdup_printf ("%s/%uXXXXXX%s", tmpdir,
|
||||||
g_str_hash (uri), midori_view_fallback_extension (view, extension));
|
g_str_hash (uri), midori_view_fallback_extension (view, extension));
|
||||||
g_free (tmpdir);
|
g_free (tmpdir);
|
||||||
|
|
|
@ -289,6 +289,9 @@ const gchar*
|
||||||
midori_view_fallback_extension (MidoriView* view,
|
midori_view_fallback_extension (MidoriView* view,
|
||||||
const gchar* extension);
|
const gchar* extension);
|
||||||
|
|
||||||
|
gchar*
|
||||||
|
midori_view_get_tmp_dir (void);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __MIDORI_VIEW_H__ */
|
#endif /* __MIDORI_VIEW_H__ */
|
||||||
|
|
Loading…
Reference in a new issue