Skip to content

Commit

Permalink
Re-enable util_datadir check disabled in bitcoin#20744
Browse files Browse the repository at this point in the history
This should also fix an assert error if a -datadir with a trailing slash
is used on windows. This appears to be a real error and regression
introduced with bitcoin#20744.

On windows (or at least wine), fs calls that actuallly access the
filesystem like fs::equivalent or fs::exists seem to treat directory
paths with trailing slashes as not existing, so it's necessary to
normalize these paths before using them. This fix adds a
path::lexically_normal() call to the failing assert so it passes.
  • Loading branch information
ryanofsky authored and jagdeep sidhu committed Feb 6, 2022
1 parent 6f08375 commit a603a53
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions src/test/util_tests.cpp
Expand Up @@ -71,12 +71,9 @@ BOOST_AUTO_TEST_CASE(util_datadir)
args.ClearPathCache();
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());

#ifndef WIN32
// Windows does not consider "datadir/.//" to be a valid directory path.
args.ForceSetArg("-datadir", fs::PathToString(dd_norm) + "/.//");
args.ClearPathCache();
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
#endif
}

BOOST_AUTO_TEST_CASE(util_check)
Expand Down
2 changes: 1 addition & 1 deletion src/util/system.cpp
Expand Up @@ -270,7 +270,7 @@ fs::path StripRedundantLastElementsOfPath(const fs::path& path)
result = result.parent_path();
}

assert(fs::equivalent(result, path));
assert(fs::equivalent(result, path.lexically_normal()));
return result;
}
} // namespace
Expand Down

0 comments on commit a603a53

Please sign in to comment.