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

Unified Diff: sql/connection.cc

Issue 1176653002: mandoline filesystem: add a sqlite3 vfs to proxy filesystem usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch cleanup now that gn check passes. Created 5 years, 6 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
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index c196073ebfb549d39340316e4437e7f2c7cb61b5..b3f1ad8a2bf0684c5cf0187db8e3cb0a8f456b4a 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -607,6 +607,14 @@ void Connection::Poison() {
poisoned_ = true;
}
+std::string AsUTF8ForSQL(const base::FilePath& path) {
+#if defined(OS_WIN)
+ return base::WideToUTF8(path.value());
+#elif defined(OS_POSIX)
+ return path.value();
+#endif
+}
+
// TODO(shess): To the extent possible, figure out the optimal
// ordering for these deletes which will prevent other connections
// from seeing odd behavior. For instance, it may be necessary to
@@ -624,13 +632,32 @@ bool Connection::Delete(const base::FilePath& path) {
base::FilePath journal_path(path.value() + FILE_PATH_LITERAL("-journal"));
base::FilePath wal_path(path.value() + FILE_PATH_LITERAL("-wal"));
- base::DeleteFile(journal_path, false);
- base::DeleteFile(wal_path, false);
- base::DeleteFile(path, false);
+ std::string journal_str = AsUTF8ForSQL(journal_path);
+ std::string wal_str = AsUTF8ForSQL(wal_path);
+ std::string path_str = AsUTF8ForSQL(path);
+
+ sqlite3_vfs* vfs = sqlite3_vfs_find(NULL);
Scott Hess - ex-Googler 2015/06/10 22:35:45 I don't think it's appropriate to change this code
Elliot Glaysher 2015/06/12 22:36:43 Per our conversation yesterday, I added a check on
Scott Hess - ex-Googler 2015/06/17 19:32:58 I'm happier with it, though not ecstatic. At leas
+ CHECK(vfs);
+ CHECK(vfs->xDelete);
+ CHECK(vfs->xAccess);
+
+ vfs->xDelete(vfs, journal_str.c_str(), 0);
+ vfs->xDelete(vfs, wal_str.c_str(), 0);
+ vfs->xDelete(vfs, path_str.c_str(), 0);
+
+ int journal_exists = 0;
+ vfs->xAccess(vfs, journal_str.c_str(), SQLITE_ACCESS_EXISTS,
+ &journal_exists);
+
+ int wal_exists = 0;
+ vfs->xAccess(vfs, wal_str.c_str(), SQLITE_ACCESS_EXISTS,
+ &wal_exists);
+
+ int path_exists = 0;
+ vfs->xAccess(vfs, path_str.c_str(), SQLITE_ACCESS_EXISTS,
+ &path_exists);
- return !base::PathExists(journal_path) &&
- !base::PathExists(wal_path) &&
- !base::PathExists(path);
+ return !journal_exists && !wal_exists && !path_exists;
}
bool Connection::BeginTransaction() {

Powered by Google App Engine
This is Rietveld 408576698