[epiphany/mcatanzaro/#1733: 9/9] download: "ask on download" should not clobber files of same name
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/#1733: 9/9] download: "ask on download" should not clobber files of same name
- Date: Mon, 11 Apr 2022 14:38:39 +0000 (UTC)
commit 70c8e6af3e1e0554dce4cd184eba5db09341a44a
Author: Michael Catanzaro <mcatanzaro redhat com>
Date: Tue Apr 5 15:48:21 2022 -0500
download: "ask on download" should not clobber files of same name
When the ask on download setting is enabled, we accidentally do not call
the existing code that ensures that we don't overwrite an existing file
of the same name by appending (1), (2), etc. to the filename. Oops.
Fixes #1712
Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1103>
embed/ephy-download.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/embed/ephy-download.c b/embed/ephy-download.c
index 795b3da9d..b8f294dd2 100644
--- a/embed/ephy-download.c
+++ b/embed/ephy-download.c
@@ -193,6 +193,7 @@ parse_extension (const char *filename)
static gboolean
set_destination_uri_for_suggested_filename (EphyDownload *download,
+ const char *directory,
const char *suggested_filename)
{
char *dest_dir;
@@ -200,7 +201,10 @@ set_destination_uri_for_suggested_filename (EphyDownload *download,
char *destination_filename;
char *destination_uri;
- dest_dir = ephy_file_get_downloads_dir ();
+ if (directory)
+ dest_dir = g_strdup (directory);
+ else
+ dest_dir = ephy_file_get_downloads_dir ();
/* Make sure the download directory exists */
if (g_mkdir_with_parents (dest_dir, 0700) == -1) {
@@ -602,18 +606,16 @@ filename_suggested_dialog_cb (GtkDialog *dialog,
SuggestedFilenameData *data)
{
if (response == GTK_RESPONSE_OK) {
- g_autofree gchar *folder_path = g_file_get_path (data->directory);
- g_autofree gchar *folder_uri = g_file_get_uri (data->directory);
- g_autofree gchar *download_uri = g_build_filename (folder_uri, data->suggested_filename, NULL);
+ g_autofree gchar *directory = g_file_get_path (data->directory);
- ephy_download_set_destination_uri (data->download, download_uri);
+ set_destination_uri_for_suggested_filename (data->download, directory, data->suggested_filename);
webkit_download_set_allow_overwrite (data->webkit_download, TRUE);
ephy_downloads_manager_add_download (ephy_embed_shell_get_downloads_manager
(ephy_embed_shell_get_default ()),
data->download);
- g_settings_set_string (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_LAST_DOWNLOAD_DIRECTORY, folder_path);
+ g_settings_set_string (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_LAST_DOWNLOAD_DIRECTORY, directory);
data->result = TRUE;
} else {
ephy_download_cancel (data->download);
@@ -826,7 +828,7 @@ download_decide_destination_cb (WebKitDownload *wk_download,
g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ASK_ON_DOWNLOAD))
return run_download_confirmation_dialog (download, suggested_filename);
- return set_destination_uri_for_suggested_filename (download, suggested_filename);
+ return set_destination_uri_for_suggested_filename (download, NULL, suggested_filename);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]