Changeset 173154 in webkit


Ignore:
Timestamp:
Sep 1, 2014 1:35:52 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[SOUP] WebKitDownload cannot overwrite existing file
https://bugs.webkit.org/show_bug.cgi?id=136322

Patch by Michael Catanzaro <Michael Catanzaro> on 2014-09-01
Reviewed by Carlos Garcia Campos.

  • Shared/Downloads/soup/DownloadSoup.cpp:

(WebKit::DownloadClient::didReceiveResponse): pass a member variable
to Download::decideDestinationWithSuggestedFilename instead of a
temporary bool, so we can use the result in didFinishLoading.
(WebKit::DownloadClient::didFinishLoading): overwrite the destination
if Download::decideDestinationWithSuggestedFilename determined we
should do so.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r173144 r173154  
     12014-09-01  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [SOUP] WebKitDownload cannot overwrite existing file
     4        https://bugs.webkit.org/show_bug.cgi?id=136322
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * Shared/Downloads/soup/DownloadSoup.cpp:
     9        (WebKit::DownloadClient::didReceiveResponse): pass a member variable
     10        to Download::decideDestinationWithSuggestedFilename instead of a
     11        temporary bool, so we can use the result in didFinishLoading.
     12        (WebKit::DownloadClient::didFinishLoading): overwrite the destination
     13        if Download::decideDestinationWithSuggestedFilename determined we
     14        should do so.
     15
    1162014-08-31  Tim Horton  <timothy_horton@apple.com>
    217
  • trunk/Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp

    r169782 r173154  
    5151    DownloadClient(Download* download)
    5252        : m_download(download)
     53        , m_allowOverwrite(false)
    5354    {
    5455    }
     
    8990        }
    9091
    91         bool overwrite;
    92         m_destinationURI = m_download->decideDestinationWithSuggestedFilename(suggestedFilename, overwrite);
     92        m_destinationURI = m_download->decideDestinationWithSuggestedFilename(suggestedFilename, m_allowOverwrite);
    9393        if (m_destinationURI.isEmpty()) {
    9494#if PLATFORM(GTK)
     
    138138        GRefPtr<GFile> destinationFile = adoptGRef(g_file_new_for_uri(m_destinationURI.utf8().data()));
    139139        GUniqueOutPtr<GError> error;
    140         if (!g_file_move(m_intermediateFile.get(), destinationFile.get(), G_FILE_COPY_NONE, nullptr, nullptr, nullptr, &error.outPtr())) {
     140        if (!g_file_move(m_intermediateFile.get(), destinationFile.get(), m_allowOverwrite ? G_FILE_COPY_OVERWRITE : G_FILE_COPY_NONE, nullptr, nullptr, nullptr, &error.outPtr())) {
    141141            downloadFailed(platformDownloadDestinationError(m_response, error->message));
    142142            return;
     
    198198    ResourceResponse m_delayedResponse;
    199199    GMainLoopSource m_handleResponseLater;
     200    bool m_allowOverwrite;
    200201};
    201202
Note: See TracChangeset for help on using the changeset viewer.