WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
136322
[SOUP] WebKitDownload cannot overwrite existing file
https://bugs.webkit.org/show_bug.cgi?id=136322
Summary
[SOUP] WebKitDownload cannot overwrite existing file
Michael Catanzaro
Reported
2014-08-27 17:03:01 PDT
If the destination of a WebKitDownload is a file that already exists, the download will always fail. This is awkward because some browsers want to allow users to save a downloaded file over an existing file. For example, in Epiphany if you use the Save Image As feature (right click on an image) and try to save over a file that already exists, we have a dialog box to confirm that the user really wants to overwrite the file -> user confirms he wants to overwrite the file -> download fails with error message "file already exists."
Attachments
Patch
(1.73 KB, patch)
2014-08-27 17:06 PDT
,
Michael Catanzaro
no flags
Details
Formatted Diff
Diff
Patch
(2.87 KB, patch)
2014-08-29 09:25 PDT
,
Michael Catanzaro
no flags
Details
Formatted Diff
Diff
Patch
(3.02 KB, patch)
2014-08-31 11:30 PDT
,
Michael Catanzaro
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Michael Catanzaro
Comment 1
2014-08-27 17:06:41 PDT
Created
attachment 237271
[details]
Patch
Sergio Villar Senin
Comment 2
2014-08-28 00:12:19 PDT
Comment on
attachment 237271
[details]
Patch Not sure we unconditionally want to overwrite an existing file, we should be careful with destructive operations.
Carlos Garcia Campos
Comment 3
2014-08-28 00:23:54 PDT
Comment on
attachment 237271
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=237271&action=review
Doing this unconditionally might be dangerous. I think it might make sense to allow overwrite when the destination has been set by the application explicitly, since apps are supposed to handle that situation when deciding the destination name, but we should document that. When the destination is decided automatically by WebKit, I'm not sure sure it's a good idea to overwrite existing file, though. The safest way would be to add API for that something like webkit_download_set_allow_overwrite()
> Source/WebKit2/ChangeLog:3 > + [GTK] WebKitDownload cannot overwrite existing file
This is not a GTK specific issue, it affects all ports using libsoup as network backend.
> Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp:140 > - if (!g_file_move(m_intermediateFile.get(), destinationFile.get(), G_FILE_COPY_NONE, nullptr, nullptr, nullptr, &error.outPtr())) { > + if (!g_file_move(m_intermediateFile.get(), destinationFile.get(), G_FILE_COPY_OVERWRITE, nullptr, nullptr, nullptr, &error.outPtr())) {
I think this should be done using the allowOverwrite parameter of DecideDestinationWithSuggestedFilename message, so that clients can decide and it won't affect EFL in this case.
Carlos Garcia Campos
Comment 4
2014-08-28 00:26:19 PDT
So, I would split this patch. In this bug I would make sure we use the allowOverwrite parameter that we are currently ignoring, adding G_FILE_COPY_OVERWRITE flag when it's true (it will be false anyway, so there's no change in behaviour). And then I would open a new bug for the GTK port to decide how to handle overwrites in the GTK+ API.
Michael Catanzaro
Comment 5
2014-08-29 09:25:21 PDT
Created
attachment 237352
[details]
Patch
Carlos Garcia Campos
Comment 6
2014-08-29 09:51:54 PDT
Comment on
attachment 237352
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=237352&action=review
Thanks, I have a few minor comments.
> Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp:91 > - m_destinationURI = m_download->decideDestinationWithSuggestedFilename(suggestedFilename, overwrite); > + m_destinationURI = m_download->decideDestinationWithSuggestedFilename(suggestedFilename, m_overwriteDestination);
Nit: I would use m_allowOverwrite for consistency with the IPC message param name.
> Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp:140 > - if (!g_file_move(m_intermediateFile.get(), destinationFile.get(), G_FILE_COPY_NONE, nullptr, nullptr, nullptr, &error.outPtr())) { > + if (!g_file_move(m_intermediateFile.get(), destinationFile.get(), flags, nullptr, nullptr, nullptr, &error.outPtr())) {
I think you can add the if directly here, without the local variable if (!g_file_move(m_intermediateFile.get(), destinationFile.get(), m_allowOverwrite ? G_FILE_COPY_OVERWRITE : G_FILE_COPY_NONE, nullptr, nullptr, nullptr, &error.outPtr())) {
> Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp:200 > + bool m_overwriteDestination = false;
Initialize the member in the constructor.
Michael Catanzaro
Comment 7
2014-08-31 11:30:59 PDT
Created
attachment 237430
[details]
Patch
WebKit Commit Bot
Comment 8
2014-09-01 01:36:02 PDT
Comment on
attachment 237430
[details]
Patch Clearing flags on attachment: 237430 Committed
r173154
: <
http://trac.webkit.org/changeset/173154
>
WebKit Commit Bot
Comment 9
2014-09-01 01:36:04 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug