From 33ab0cd7bd1eec167f931134bd2b07de0fc31c20 Mon Sep 17 00:00:00 2001 From: Yusuf Sahin HAMZA Date: Mon, 2 Sep 2019 02:44:51 +0300 Subject: [PATCH] Automatically update NodeDB path if changed --- src/ripple/app/misc/SHAMapStoreImp.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/ripple/app/misc/SHAMapStoreImp.cpp b/src/ripple/app/misc/SHAMapStoreImp.cpp index 082b8a2363..ff39d171f7 100644 --- a/src/ripple/app/misc/SHAMapStoreImp.cpp +++ b/src/ripple/app/misc/SHAMapStoreImp.cpp @@ -488,6 +488,30 @@ SHAMapStoreImp::dbPaths() } SavedState state = state_db_.getState(); + + { + auto update = [&dbPath](std::string& sPath) + { + if (sPath.empty()) + return false; + + // Check if configured "path" matches stored directory path + using namespace boost::filesystem; + auto const stored {path(sPath)}; + if (stored.parent_path() == dbPath) + return false; + + sPath = (dbPath / stored.filename()).string(); + return true; + }; + + if (update(state.writableDb)) + { + update(state.archiveDb); + state_db_.setState(state); + } + } + bool writableDbExists = false; bool archiveDbExists = false;