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

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

Issue 2877008: Rename the download to its final name only after the download is finished (Closed)
Patch Set: rebase Created 10 years, 5 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 | « chrome/browser/download/download_file.h ('k') | chrome/browser/download/download_file_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_file.cc
diff --git a/chrome/browser/download/download_file.cc b/chrome/browser/download/download_file.cc
index 81d80b4c89cab028d419c3c9b1c48964b63f82e4..837d37eca445776355a6105f803100641e9e0bbd 100644
--- a/chrome/browser/download/download_file.cc
+++ b/chrome/browser/download/download_file.cc
@@ -62,11 +62,11 @@ void DownloadFile::Cancel() {
}
// The UI has provided us with our finalized name.
-bool DownloadFile::Rename(const FilePath& new_path) {
+bool DownloadFile::Rename(const FilePath& new_path, bool is_final_rename) {
// If the new path is same as the old one, there is no need to perform the
// following renaming logic.
if (new_path == full_path_) {
- path_renamed_ = true;
+ path_renamed_ = is_final_rename;
// Don't close the file if we're not done (finished or canceled).
if (!in_progress_)
@@ -77,6 +77,8 @@ bool DownloadFile::Rename(const FilePath& new_path) {
Close();
+ file_util::CreateDirectory(new_path.DirName());
+
#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
@@ -106,7 +108,7 @@ bool DownloadFile::Rename(const FilePath& new_path) {
#endif
full_path_ = new_path;
- path_renamed_ = true;
+ path_renamed_ = is_final_rename;
// We don't need to re-open the file if we're done (finished or canceled).
if (!in_progress_)
@@ -122,6 +124,11 @@ bool DownloadFile::Rename(const FilePath& new_path) {
return true;
}
+void DownloadFile::DeleteCrDownload() {
+ FilePath crdownload = download_util::GetCrDownloadPath(full_path_);
+ file_util::Delete(crdownload, false);
+}
+
void DownloadFile::Close() {
if (file_stream_.get()) {
#if defined(OS_CHROMEOS)
« no previous file with comments | « chrome/browser/download/download_file.h ('k') | chrome/browser/download/download_file_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698