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

Unified Diff: third_party/leveldatabase/env_chromium.cc

Issue 14886003: Make base:ReplaceFile return an informative error. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ToT Created 7 years, 7 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/platform_file_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/leveldatabase/env_chromium.cc
diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc
index a512e311f2d35f9890286484e7ecad3f16561401..ee19ba14160be6181b04cf28761b254547fb31d7 100644
--- a/third_party/leveldatabase/env_chromium.cc
+++ b/third_party/leveldatabase/env_chromium.cc
@@ -202,7 +202,7 @@ static const base::FilePath::CharType kLevelDBTestDirectoryPrefix[]
const char* PlatformFileErrorString(const ::base::PlatformFileError& error) {
switch (error) {
case ::base::PLATFORM_FILE_ERROR_FAILED:
- return "Opening file failed.";
+ return "No further details.";
case ::base::PLATFORM_FILE_ERROR_IN_USE:
return "File currently in use.";
case ::base::PLATFORM_FILE_ERROR_EXISTS:
@@ -549,8 +549,10 @@ class ChromiumEnv : public Env, public UMALogger {
base::FilePath destination = CreateFilePath(dst);
Retrier retrier(GetRetryTimeHistogram(kRenameFile), kMaxRenameTimeMillis);
+ base::PlatformFileError error = base::PLATFORM_FILE_OK;
do {
- if (::file_util::ReplaceFile(src_file_path, destination)) {
+ if (::file_util::ReplaceFileAndGetError(
+ src_file_path, destination, &error)) {
sync_parent(dst);
if (src != dst)
sync_parent(src);
@@ -558,8 +560,12 @@ class ChromiumEnv : public Env, public UMALogger {
}
} while (retrier.ShouldKeepTrying());
- RecordErrorAt(kRenameFile);
- return Status::IOError(src, "Could not rename file.");
+ DCHECK(error != base::PLATFORM_FILE_OK);
+ RecordOSError(kRenameFile, error);
+ char buf[100];
+ snprintf(buf, sizeof(buf), "Could not rename file: %s",
+ PlatformFileErrorString(error));
+ return Status::IOError(src, buf);
}
virtual Status LockFile(const std::string& fname, FileLock** lock) {
« no previous file with comments | « base/platform_file_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698