summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-27 19:27:31 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-27 19:27:31 +0000
commit9371dc31f827d0e7be9151973facf1577dea610b (patch)
treeec41ba74caba6016c70fc703f8823a508658dfc4 /chrome
parentb94783782021f718f2ec674b54bf7a84f30c3632 (diff)
downloadchromium_src-9371dc31f827d0e7be9151973facf1577dea610b.zip
chromium_src-9371dc31f827d0e7be9151973facf1577dea610b.tar.gz
chromium_src-9371dc31f827d0e7be9151973facf1577dea610b.tar.bz2
Changes saving of prefs/bookmarks to try move a second time if first
time fails. BUG=1347276 TEST=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1458 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/bookmark_storage.cc11
-rw-r--r--chrome/common/pref_service.cc11
2 files changed, 18 insertions, 4 deletions
diff --git a/chrome/browser/bookmark_storage.cc b/chrome/browser/bookmark_storage.cc
index e944de7..e9d3395 100644
--- a/chrome/browser/bookmark_storage.cc
+++ b/chrome/browser/bookmark_storage.cc
@@ -137,8 +137,15 @@ void BookmarkStorageBackend::Write(Value* value) {
int bytes_written = file_util::WriteFile(tmp_file, content.c_str(),
static_cast<int>(content.length()));
if (bytes_written != -1) {
- MoveFileEx(tmp_file.c_str(), path_.c_str(),
- MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
+ if (!MoveFileEx(tmp_file.c_str(), path_.c_str(),
+ MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) {
+ // Rename failed. Try again on the off chance someone has locked either
+ // file and hope we're successful the second time through.
+ BOOL move_result =
+ MoveFileEx(tmp_file.c_str(), path_.c_str(),
+ MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
+ DCHECK(move_result);
+ }
// Nuke the history file so that we don't attempt to load from it again.
file_util::Delete(tmp_history_path_, false);
}
diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
index 60ac6f2..5e2f319 100644
--- a/chrome/common/pref_service.cc
+++ b/chrome/common/pref_service.cc
@@ -40,8 +40,15 @@ class SaveLaterTask : public Task {
int bytes_written = file_util::WriteFile(tmp_file_name, data_.c_str(),
static_cast<int>(data_.length()));
if (bytes_written != -1) {
- MoveFileEx(tmp_file_name.c_str(), file_name_.c_str(),
- MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
+ if (!MoveFileEx(tmp_file_name.c_str(), file_name_.c_str(),
+ MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) {
+ // Rename failed. Try again on the off chance someone has locked either
+ // file and hope we're successful the second time through.
+ BOOL move_result =
+ MoveFileEx(tmp_file_name.c_str(), file_name_.c_str(),
+ MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
+ DCHECK(move_result);
+ }
}
}