Skip to content

Commit 7efc628

Browse files
committed
Merge bitcoin/bitcoin#23385: refactor: get wallet path relative to wallet_dir
9ba7c44 refactor: get wallet path relative to wallet_dir (Michael Dietz) Pull request description: Now that boost has been updated > 1.60 (see #22320), we can simplify how we get wallet path relative to wallet_dir by using: `boost::filesystem::lexically_relative`, removing a TODO. Test coverage comes from `test/functional/wallet_multiwallet.py` I first tried this in #20265 which was my first attempted PR, and funny enough exactly 1 year later I'm opening this one to hopefully finally close this. ACKs for top commit: ryanofsky: Code review ACK 9ba7c44. Basically this same code change is made in #20744 commit b70c84348ac7a8e427a1183f894c73e52c734529, so this PR helps simplify that one lsilva01: Code Review ACK 9ba7c44 Tree-SHA512: 6ccb91a18bcb52c3ae0c789a94a18fb5be7db7769fd1121552d63f259fbd32b50c3dcf169cec0b02f978321db3bc60eb4b881b8327e9764f32e700236e0d8a35
2 parents 5574881 + 9ba7c44 commit 7efc628

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/wallet/db.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
1414
{
15-
const size_t offset = wallet_dir.native().size() + (wallet_dir == wallet_dir.root_name() ? 0 : 1);
1615
std::vector<fs::path> paths;
1716
boost::system::error_code ec;
1817

@@ -28,10 +27,7 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
2827
}
2928

3029
try {
31-
// Get wallet path relative to walletdir by removing walletdir from the wallet path.
32-
// This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60.
33-
const auto path_str = it->path().native().substr(offset);
34-
const fs::path path{path_str.begin(), path_str.end()};
30+
const fs::path path{it->path().lexically_relative(wallet_dir)};
3531

3632
if (it->status().type() == fs::directory_file &&
3733
(IsBDBFile(BDBDataFile(it->path())) || IsSQLiteFile(SQLiteDataFile(it->path())))) {

0 commit comments

Comments
 (0)