Automatically update NodeDB path if changed

This commit is contained in:
Yusuf Sahin HAMZA
2019-09-02 02:44:51 +03:00
committed by Manoj doshi
parent e33ac1d450
commit 33ab0cd7bd

View File

@@ -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;