fixing broken tests on Windows, merge GetDataDir fixes
This commit is contained in:
parent
4a6b3b7bf2
commit
91760d0252
5 changed files with 28 additions and 13 deletions
|
@ -1649,7 +1649,7 @@ bool AppInitMain(InitInterfaces& interfaces)
|
||||||
if (fReindex) {
|
if (fReindex) {
|
||||||
// remove old LevelDB indexes
|
// remove old LevelDB indexes
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
fs::remove_all(GetDataDir() / "blocks" / "index", ec);
|
fs::remove_all(GetBlocksDir() / "index", ec);
|
||||||
fs::remove_all(GetDataDir() / "chainstate", ec);
|
fs::remove_all(GetDataDir() / "chainstate", ec);
|
||||||
fs::remove_all(GetDataDir() / "claimtrie", ec);
|
fs::remove_all(GetDataDir() / "claimtrie", ec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -549,6 +549,12 @@ void ArgsManager::ForceSetArg(const std::string& strArg, const std::string& strV
|
||||||
m_override_args[strArg] = {strValue};
|
m_override_args[strArg] = {strValue};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArgsManager::ForceClearArg(const std::string& strArg)
|
||||||
|
{
|
||||||
|
LOCK(cs_args);
|
||||||
|
m_override_args.erase(strArg);
|
||||||
|
}
|
||||||
|
|
||||||
void ArgsManager::AddArg(const std::string& name, const std::string& help, unsigned int flags, const OptionsCategory& cat)
|
void ArgsManager::AddArg(const std::string& name, const std::string& help, unsigned int flags, const OptionsCategory& cat)
|
||||||
{
|
{
|
||||||
// Split arg name from its help param
|
// Split arg name from its help param
|
||||||
|
@ -735,16 +741,21 @@ const fs::path &GetBlocksDir()
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-blocksdir")) {
|
if (gArgs.IsArgSet("-blocksdir")) {
|
||||||
path = fs::system_complete(gArgs.GetArg("-blocksdir", ""));
|
path = fs::system_complete(gArgs.GetArg("-blocksdir", ""));
|
||||||
if (!fs::is_directory(path)) {
|
if (fs::exists(path) && !fs::is_directory(path)) {
|
||||||
path = "";
|
LogPrintf("%s: %s is not a directory, falling back to GetDataDir\n", __func__, path);
|
||||||
return path;
|
path.clear();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
path = GetDataDir(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool usingDataDir = path.empty();
|
||||||
|
if (usingDataDir)
|
||||||
|
path = GetDataDir(false);
|
||||||
|
|
||||||
path /= BaseParams().DataDir();
|
path /= BaseParams().DataDir();
|
||||||
|
|
||||||
|
if (usingDataDir)
|
||||||
path /= "blocks";
|
path /= "blocks";
|
||||||
|
|
||||||
fs::create_directories(path);
|
fs::create_directories(path);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -761,13 +772,15 @@ const fs::path &GetDataDir(bool fNetSpecific)
|
||||||
std::string datadir = gArgs.GetArg("-datadir", "");
|
std::string datadir = gArgs.GetArg("-datadir", "");
|
||||||
if (!datadir.empty()) {
|
if (!datadir.empty()) {
|
||||||
path = fs::system_complete(datadir);
|
path = fs::system_complete(datadir);
|
||||||
if (!fs::is_directory(path)) {
|
if (fs::exists(path) && !fs::is_directory(path)) {
|
||||||
path = "";
|
LogPrintf("%s: %s is not a directory, falling back to GetDefaultDataDir\n", __func__, path);
|
||||||
return path;
|
path.clear();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (path.empty())
|
||||||
path = GetDefaultDataDir();
|
path = GetDefaultDataDir();
|
||||||
}
|
|
||||||
if (fNetSpecific)
|
if (fNetSpecific)
|
||||||
path /= BaseParams().DataDir();
|
path /= BaseParams().DataDir();
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,7 @@ public:
|
||||||
// Forces an arg setting. Called by SoftSetArg() if the arg hasn't already
|
// Forces an arg setting. Called by SoftSetArg() if the arg hasn't already
|
||||||
// been set. Also called directly in testing.
|
// been set. Also called directly in testing.
|
||||||
void ForceSetArg(const std::string& strArg, const std::string& strValue);
|
void ForceSetArg(const std::string& strArg, const std::string& strValue);
|
||||||
|
void ForceClearArg(const std::string& strArg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
|
* Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
|
||||||
|
|
|
@ -4771,7 +4771,7 @@ bool LoadBlockIndex(const CChainParams& chainparams)
|
||||||
needs_init = g_blockman.m_block_index.empty();
|
needs_init = g_blockman.m_block_index.empty();
|
||||||
|
|
||||||
if (needs_init) {
|
if (needs_init) {
|
||||||
auto blockDir = GetDataDir() / "blocks";
|
auto& blockDir = GetBlocksDir();
|
||||||
for (auto it: fs::directory_iterator(blockDir)) {
|
for (auto it: fs::directory_iterator(blockDir)) {
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
if (fs::file_size(it, ec) > 100000000) {
|
if (fs::file_size(it, ec) > 100000000) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainNam
|
||||||
|
|
||||||
InitWalletDirTestingSetup::~InitWalletDirTestingSetup()
|
InitWalletDirTestingSetup::~InitWalletDirTestingSetup()
|
||||||
{
|
{
|
||||||
|
gArgs.ForceClearArg("-walletdir");
|
||||||
fs::current_path(m_cwd);
|
fs::current_path(m_cwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue