aboutsummaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-05-03 15:17:33 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2013-05-03 15:17:33 -0700
commit674ae7a26fbcd97a37e7a6fb2e26d186e872e354 (patch)
treec0712b4839fd1518db5bdf432868d7f9c95256fc /src/db.cpp
parent979a22a7a07b8336a3762a09fd035f58d3d4d06f (diff)
parentccda03b57022369c4352d0f5a816cff9ace833e6 (diff)
Merge pull request #2558 from sipa/nodbdir
Some database/-related recovery improvements
Diffstat (limited to 'src/db.cpp')
-rw-r--r--src/db.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 35d6cca890..52d613bc3b 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -38,7 +38,7 @@ void CDBEnv::EnvShutdown()
if (ret != 0)
printf("EnvShutdown exception: %s (%d)\n", DbEnv::strerror(ret), ret);
if (!fMockDb)
- DbEnv(0).remove(strPath.c_str(), 0);
+ DbEnv(0).remove(path.string().c_str(), 0);
}
CDBEnv::CDBEnv() : dbenv(DB_CXX_NO_EXCEPTIONS)
@@ -57,14 +57,14 @@ void CDBEnv::Close()
EnvShutdown();
}
-bool CDBEnv::Open(const boost::filesystem::path& path)
+bool CDBEnv::Open(const boost::filesystem::path& pathIn)
{
if (fDbEnvInit)
return true;
boost::this_thread::interruption_point();
- strPath = path.string();
+ path = pathIn;
filesystem::path pathLogDir = path / "database";
filesystem::create_directory(pathLogDir);
filesystem::path pathErrorFile = path / "db.log";
@@ -84,7 +84,7 @@ bool CDBEnv::Open(const boost::filesystem::path& path)
dbenv.set_flags(DB_AUTO_COMMIT, 1);
dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1);
dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1);
- int ret = dbenv.open(strPath.c_str(),
+ int ret = dbenv.open(path.string().c_str(),
DB_CREATE |
DB_INIT_LOCK |
DB_INIT_LOG |
@@ -456,6 +456,8 @@ void CDBEnv::Flush(bool fShutdown)
{
dbenv.log_archive(&listp, DB_ARCH_REMOVE);
Close();
+ if (!fMockDb)
+ boost::filesystem::remove_all(path / "database");
}
}
}