Commit 873c597b authored by Brannon King's avatar Brannon King
Browse files

don't require pre-existence of datadir

parent 1804bba5
......@@ -461,8 +461,10 @@ bool CClaimTrieCacheBase::checkConsistency()
int takeoverHeight;
row >> name >> hash >> takeoverHeight;
auto computedHash = computeNodeHash(name, takeoverHeight);
if (computedHash != hash)
if (computedHash != hash) {
logPrint << "Invalid hash at " << name << Clog::endl;
return false;
}
}
return true;
}
......
......@@ -703,19 +703,22 @@ const fs::path &GetBlocksDir(bool fNetSpecific)
if (gArgs.IsArgSet("-blocksdir")) {
path = fs::system_complete(gArgs.GetArg("-blocksdir", ""));
if (!fs::is_directory(path)) {
LogPrintf("%s: %s is not a directory, fallback to GetDataDir\n", __func__, path);
if (fs::exists(path) && !fs::is_directory(path)) {
LogPrintf("%s: %s is not a directory, falling back to GetDataDir\n", __func__, path);
path.clear();
}
}
if (path.empty())
bool usingDataDir = path.empty();
if (usingDataDir)
path = GetDataDir(false);
if (fNetSpecific)
path /= BaseParams().DataDir();
path /= "blocks";
if (usingDataDir)
path /= "blocks";
fs::create_directories(path);
return path;
}
......@@ -734,8 +737,8 @@ const fs::path &GetDataDir(bool fNetSpecific)
if (gArgs.IsArgSet("-datadir")) {
path = fs::system_complete(gArgs.GetArg("-datadir", ""));
if (!fs::is_directory(path)) {
LogPrintf("%s: %s is not a directory, fallback to GetDefaultDataDir\n", __func__, path);
if (fs::exists(path) && !fs::is_directory(path)) {
LogPrintf("%s: %s is not a directory, falling back to GetDefaultDataDir\n", __func__, path);
path.clear();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment