RESOLVED FIXED 53668
Download bundles should be moved to their final destination when they finish
https://bugs.webkit.org/show_bug.cgi?id=53668
Summary Download bundles should be moved to their final destination when they finish
Jon Honeycutt
Reported 2011-02-03 01:27:37 PST
Download bundles created by the CFNetwork port should be moved to their final location when they finish downloading.
Attachments
Patch (13.61 KB, patch)
2011-02-03 01:54 PST, Jon Honeycutt
aroben: review+
Patch v2 (15.07 KB, patch)
2011-02-03 17:09 PST, Jon Honeycutt
aroben: review+
Jon Honeycutt
Comment 1 2011-02-03 01:54:39 PST
Adam Roben (:aroben)
Comment 2 2011-02-03 05:42:14 PST
Comment on attachment 81044 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=81044&action=review > Source/WebKit2/WebProcess/Downloads/win/DownloadWin.cpp:35 > +#if USE(CFNETWORK) If this is CFNetwork- and Windows-specific, maybe this file should be Downloads\cf\win\DownloadsCFNetWin.cpp. That would match what has been done with GraphicsContext. > Source/WebKit2/WebProcess/Downloads/win/DownloadWin.cpp:36 > + ASSERT(!m_bundlePath.isEmpty() && !m_destination.isEmpty()); Please use two ASSERTs. > Source/WebKit2/WebProcess/Downloads/win/DownloadWin.cpp:40 > + // Try to move the bundle to the final filename. > + if (MoveFileEx(m_bundlePath.charactersWithNullTermination(), m_destination.charactersWithNullTermination(), 0)) > + return; That should be ::MoveFileExW. Should we pass MOVEFILE_COPY_ALLOWED? And if the UI process said we're allowed to overwrite an existing file, shouldn't we also pass MOVEFILE_REPLACE_EXISTING? (That would require passing allowOverwrite to platformDidFinish.) Is it a bug that we're not calling didCreateDestination in this case? > Source/WebKit2/WebProcess/Downloads/win/DownloadWin.cpp:57 > + bool reportBundlePathAsFinalPath = true; > + > + if (MoveFileEx(m_bundlePath.charactersWithNullTermination(), m_destination.charactersWithNullTermination(), 0)) > + reportBundlePathAsFinalPath = false; > + > + // We either need to report our final filename as the bundle filename or the updated destination filename. > + if (reportBundlePathAsFinalPath) > + didCreateDestination(m_bundlePath); > + else > + didCreateDestination(m_destination); Same comments here re: MoveFileEx. I think the extra boolean is just making things more complicated. You could just do: if (::MoveFileExW(...)) didCreateDestination(m_destination); else { // The move failed, so the final destination is just the bundle's current path. didCreateDestination(m_bundlePath); }
Jon Honeycutt
Comment 3 2011-02-03 15:11:46 PST
(In reply to comment #2) > (From update of attachment 81044 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=81044&action=review > > > Source/WebKit2/WebProcess/Downloads/win/DownloadWin.cpp:35 > > +#if USE(CFNETWORK) > > If this is CFNetwork- and Windows-specific, maybe this file should be Downloads\cf\win\DownloadsCFNetWin.cpp. That would match what has been done with GraphicsContext. OK, moved. > > > Source/WebKit2/WebProcess/Downloads/win/DownloadWin.cpp:36 > > + ASSERT(!m_bundlePath.isEmpty() && !m_destination.isEmpty()); > > Please use two ASSERTs. Fixed. > > > Source/WebKit2/WebProcess/Downloads/win/DownloadWin.cpp:40 > > + // Try to move the bundle to the final filename. > > + if (MoveFileEx(m_bundlePath.charactersWithNullTermination(), m_destination.charactersWithNullTermination(), 0)) > > + return; > > That should be ::MoveFileExW. Fixed. > > Should we pass MOVEFILE_COPY_ALLOWED? And if the UI process said we're allowed to overwrite an existing file, shouldn't we also pass MOVEFILE_REPLACE_EXISTING? (That would require passing allowOverwrite to platformDidFinish.) We didn't do this in old WebKit, but we probably should. I'll pass them. > > Is it a bug that we're not calling didCreateDestination in this case? No, we've already called didCreateDestination with the original destination. It's only if the destination changes that we need it call it. > > > Source/WebKit2/WebProcess/Downloads/win/DownloadWin.cpp:57 > > + bool reportBundlePathAsFinalPath = true; > > + > > + if (MoveFileEx(m_bundlePath.charactersWithNullTermination(), m_destination.charactersWithNullTermination(), 0)) > > + reportBundlePathAsFinalPath = false; > > + > > + // We either need to report our final filename as the bundle filename or the updated destination filename. > > + if (reportBundlePathAsFinalPath) > > + didCreateDestination(m_bundlePath); > > + else > > + didCreateDestination(m_destination); > > Same comments here re: MoveFileEx. Fixed. > > I think the extra boolean is just making things more complicated. You could just do: > > if (::MoveFileExW(...)) > didCreateDestination(m_destination); > else { > // The move failed, so the final destination is just the bundle's current path. > didCreateDestination(m_bundlePath); > } Fixed. Thanks! I'll upload another patch shortly.
Jon Honeycutt
Comment 4 2011-02-03 17:09:22 PST
Created attachment 81150 [details] Patch v2
Jon Honeycutt
Comment 5 2011-02-04 03:25:06 PST
Note You need to log in before you can comment on or make changes to this bug.