aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-02-08 18:32:08 +0200
committerRiccardo Spagni <ric@spagni.net>2016-02-08 18:32:08 +0200
commitde78962e1c314d7618f7b307185a7020ed9c5226 (patch)
treeb8654907f9d75eb2caa95625eb2f77dd6cd6d5a0 /src
parentMerge pull request #641 (diff)
parentcore: move the db lock to the data directory (diff)
downloadmonero-de78962e1c314d7618f7b307185a7020ed9c5226.tar.xz
Merge pull request #643
05bfb51 core: move the db lock to the data directory (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 8d50e8bfd..2479931be 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -267,7 +267,16 @@ namespace cryptonote
boost::filesystem::path folder(m_config_folder);
if (m_fakechain)
folder /= "fake";
- //
+
+ // make sure the data directory exists, and try to lock it
+ CHECK_AND_ASSERT_MES (boost::filesystem::exists(folder) || boost::filesystem::create_directories(folder), false,
+ std::string("Failed to create directory ").append(folder.string()).c_str());
+ if (!lock_db_directory (folder))
+ {
+ LOG_ERROR ("Failed to lock " << folder);
+ return false;
+ }
+
// check for blockchain.bin
try
{
@@ -313,13 +322,6 @@ namespace cryptonote
folder /= db->get_db_name();
LOG_PRINT_L0("Loading blockchain from folder " << folder.string() << " ...");
- if (!lock_db_directory (folder))
- {
- LOG_ERROR ("Failed to lock " << folder);
- delete db;
- return false;
- }
-
const std::string filename = folder.string();
// temporarily default to fastest:async:1000
blockchain_db_sync_mode sync_mode = db_async;