Bug 126686 - [SOUP] Partial file left on disk after a download fails or is cancelled in WebKit2
Summary: [SOUP] Partial file left on disk after a download fails or is cancelled in We...
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Keywords: Gtk
Depends on:
Reported: 2014-01-09 02:25 PST by Carlos Garcia Campos
Modified: 2014-01-09 08:04 PST (History)
2 users (show)

See Also:

Patch (13.94 KB, patch)
2014-01-09 02:37 PST, Carlos Garcia Campos
mrobinson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2014-01-09 02:25:19 PST
We are currently writing the downloads directly into the destination, and when a download fails or is cancelled after the destination has been decided, the partial file is left on the disk. Deleting the final file is not safe because there might be a race condition, so we can use an intermediate file like other browsers do, a file in the same directory than the target destination but with .wkdownload suffix, that is removed when the download fails or is cancelled. If the download finishes successfully the intermediate file is renamed to the final destination.
Comment 1 Carlos Garcia Campos 2014-01-09 02:37:48 PST
Created attachment 220706 [details]
Comment 2 Martin Robinson 2014-01-09 07:04:15 PST
Comment on attachment 220706 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=220706&action=review

> Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp:313
> +static gboolean writeNextChunkIdle(SoupMessage *message)
> +{
> +    soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, "chunk", 5);
> +    return FALSE;
> +}
> +
> +static void writeNextChunk(SoupMessage *message)

Asterisks are in the wrong place here.
Comment 3 Carlos Garcia Campos 2014-01-09 08:04:58 PST
Committed r161555: <http://trac.webkit.org/changeset/161555>