Change ClearDataDirPathCache() to ArgsManager.ClearPathCache().

pull/826/head
Kiminuo 4 years ago
parent b4190eff72
commit bb8d1c6e02

@ -90,7 +90,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
fs::create_directories(m_path_root); fs::create_directories(m_path_root);
m_args.ForceSetArg("-datadir", m_path_root.string()); m_args.ForceSetArg("-datadir", m_path_root.string());
gArgs.ForceSetArg("-datadir", m_path_root.string()); gArgs.ForceSetArg("-datadir", m_path_root.string());
ClearDatadirCache(); gArgs.ClearPathCache();
{ {
SetupServerArgs(m_node); SetupServerArgs(m_node);
std::string error; std::string error;

@ -56,19 +56,19 @@ BOOST_AUTO_TEST_CASE(util_datadir)
const fs::path dd_norm = args.GetDataDirPath(); const fs::path dd_norm = args.GetDataDirPath();
args.ForceSetArg("-datadir", dd_norm.string() + "/"); args.ForceSetArg("-datadir", dd_norm.string() + "/");
ClearDatadirCache(); args.ClearPathCache();
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath()); BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
args.ForceSetArg("-datadir", dd_norm.string() + "/."); args.ForceSetArg("-datadir", dd_norm.string() + "/.");
ClearDatadirCache(); args.ClearPathCache();
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath()); BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
args.ForceSetArg("-datadir", dd_norm.string() + "/./"); args.ForceSetArg("-datadir", dd_norm.string() + "/./");
ClearDatadirCache(); args.ClearPathCache();
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath()); BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
args.ForceSetArg("-datadir", dd_norm.string() + "/.//"); args.ForceSetArg("-datadir", dd_norm.string() + "/.//");
ClearDatadirCache(); args.ClearPathCache();
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath()); BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
} }

@ -445,7 +445,7 @@ const fs::path& ArgsManager::GetDataDirPath(bool net_specific) const
return path; return path;
} }
void ArgsManager::ClearDatadirPathCache() void ArgsManager::ClearPathCache()
{ {
LOCK(cs_args); LOCK(cs_args);
@ -813,11 +813,6 @@ bool CheckDataDirOption()
return datadir.empty() || fs::is_directory(fs::system_complete(datadir)); return datadir.empty() || fs::is_directory(fs::system_complete(datadir));
} }
void ClearDatadirCache()
{
gArgs.ClearDatadirPathCache();
}
fs::path GetConfigFile(const std::string& confPath) fs::path GetConfigFile(const std::string& confPath)
{ {
return AbsPathForConfigVal(fs::path(confPath), false); return AbsPathForConfigVal(fs::path(confPath), false);
@ -976,7 +971,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
} }
// If datadir is changed in .conf file: // If datadir is changed in .conf file:
ClearDatadirCache(); gArgs.ClearPathCache();
if (!CheckDataDirOption()) { if (!CheckDataDirOption()) {
error = strprintf("specified data directory \"%s\" does not exist.", GetArg("-datadir", "")); error = strprintf("specified data directory \"%s\" does not exist.", GetArg("-datadir", ""));
return false; return false;

@ -94,8 +94,6 @@ fs::path GetDefaultDataDir();
const fs::path &GetDataDir(bool fNetSpecific = true); const fs::path &GetDataDir(bool fNetSpecific = true);
// Return true if -datadir option points to a valid directory or is not specified. // Return true if -datadir option points to a valid directory or is not specified.
bool CheckDataDirOption(); bool CheckDataDirOption();
/** Tests only */
void ClearDatadirCache();
fs::path GetConfigFile(const std::string& confPath); fs::path GetConfigFile(const std::string& confPath);
#ifdef WIN32 #ifdef WIN32
fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true); fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
@ -281,9 +279,9 @@ public:
const fs::path& GetDataDirPath(bool net_specific = true) const; const fs::path& GetDataDirPath(bool net_specific = true) const;
/** /**
* For testing * Clear cached directory paths
*/ */
void ClearDatadirPathCache(); void ClearPathCache();
/** /**
* Return a vector of strings of the given argument * Return a vector of strings of the given argument

Loading…
Cancel
Save