Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1541)

Unified Diff: chrome/browser/download/download_file.cc

Issue 46020: Implement DownloadFile::Rename() for posix. Downloads work on linux! (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_file.cc
===================================================================
--- chrome/browser/download/download_file.cc (revision 11648)
+++ chrome/browser/download/download_file.cc (working copy)
@@ -90,17 +90,22 @@
// The UI has provided us with our finalized name.
bool DownloadFile::Rename(const FilePath& new_path) {
-#if defined(OS_WIN)
Close();
+#if defined(OS_WIN)
// We cannot rename because rename will keep the same security descriptor
// on the destination file. We want to recreate the security descriptor
// with the security that makes sense in the new path.
- if (!file_util::RenameFileAndResetSecurityDescriptor(full_path_, new_path)) {
+ if (!file_util::RenameFileAndResetSecurityDescriptor(full_path_, new_path))
return false;
- }
-
+ // TODO(estade): is this necessary?
file_util::Delete(full_path_, false);
+#elif defined(OS_POSIX)
+ // TODO(estade): Move() falls back to copying and deleting when a simple
+ // rename fails. Copying sucks for large downloads. crbug.com/8737
+ if (!file_util::Move(full_path_, new_path))
+ return false;
+#endif
full_path_ = new_path;
path_renamed_ = true;
@@ -112,11 +117,6 @@
if (!Open("a+b"))
return false;
return true;
-#elif defined(OS_POSIX)
- // TODO(port): Port this function to posix (we need file_util::Rename()).
- NOTIMPLEMENTED();
- return false;
-#endif
}
void DownloadFile::Close() {
« no previous file with comments | « base/file_util_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698